git init
: Initialize / create a new local repository. (Do this only once)git remote add origin [url without brackets]
: Connect your local repo to an online repo. (Do this only once)git add .
: Add all files to staging area.git commit -m "first commit"
: Save the changes with a message.git push origin master
: Upload changes to the master branch of your remote repository.git pull origin master
: Download and merge changes from the remote repo to your working repo.
git status
: List the files you've changed and those you still need to add or commit.git log
: Shows commit history.
-
LearnCode Academy *Highly Recommended
window.location.href = "https://github.com/dhruvdutt";
window.open("https://github.com/dhruvdutt");
document.getElementById("element-id"); // returns matched element
document.getElementsByClassName("element-class"); // returns array of matched elements
document.createElement("p");
// create a couple of elements in an otherwise empty HTML page
let heading = document.createElement("h1");
let heading_text = document.createTextNode("Big Head!");
heading.appendChild(heading_text);
document.body.appendChild(heading);
onclick
attribute
element.addEventListener("click", function() {
console.log("Listener func called");
});
<input type="text" id="inp" size="50" onkeydown="keyCode(event)"></input>
<script>
function keyCode(event) {
var x = event.keyCode;
if (x == 27) {
document.getElementById("inp").value = "";
}
}
</script>
setTimeout(function() {
console.log("Will log after 3 seconds");
}, 3000);
setInterval(function() {
console.log("Will log every 3 seconds");
}, 3000);
<p>Enter mobile number:</p>
<input type="number" onkeydown="checkNumber(this.value)">
<script>
function checkNumber(number) {
console.log(number);
}
</script>
<script>
let URL = "https://cors.io/?http://www.mocky.io/v2/5a7f23442e00005000b56873";
fetch(URL)
.then(response => response.json())
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
})
</script>