Skip to content

Instantly share code, notes, and snippets.

View nikkaroraa's full-sized avatar
👨‍💻
building!

nikhil nikkaroraa

👨‍💻
building!
View GitHub Profile
@nikkaroraa
nikkaroraa / querySelectorAll.html
Created November 13, 2017 18:52
querySelectorAll
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<body>
<p class="para">First Paragraph</p> <!-- 1st node -->
<a href="https://medium.com" class="para">Medium</a> <!-- 2nd node -->
<input type="text" class="para" /> <!-- 3rd node -->
</body>
@nikkaroraa
nikkaroraa / updatingDOMNodes.html
Created November 13, 2017 19:03
Updating DOM Nodes
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<body>
<p id="paraId">First Paragraph</p>
</body>
<script>
//accessing the node with id="paraId"
@nikkaroraa
nikkaroraa / deletingDOMnodes.html
Created November 13, 2017 19:19
Deleting DOM Nodes
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<body>
<p id="paraId">First Paragraph</p>
</body>
<script>
//accessing the node with id="paraId"
@nikkaroraa
nikkaroraa / creatingDOMnode.html
Last active November 13, 2017 19:52
Creating DOM Node
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<body>
<p id="paraId">First Paragraph</p>
</body>
<script>
//creating a new element node
@nikkaroraa
nikkaroraa / addingToDOM.html
Last active November 13, 2017 20:09
Adding to DOM
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<body>
<div class="container">
</div>
</body>
<script>
@nikkaroraa
nikkaroraa / addingToDOM2.html
Created November 13, 2017 20:07
Adding to DOM - 2
<!DOCTYPE html>
<html>
<head>
<title>DOM Manipulation</title>
</head>
<body>
<div class="container">
</div>
</body>
<script>
@nikkaroraa
nikkaroraa / fatArrowFunction.js
Last active November 26, 2017 12:21
Fat-Arrow Function
//Old syntax of defining functions
var blogTitle = function getBlogTitle(id) {
console.log(blog[id].title);
}
blogTitle(2);
//Fat-Arrow syntax
var blogTitle = id => console.log(blog[id].title);
blogTitle(2);
@nikkaroraa
nikkaroraa / implicitReturn.js
Last active November 26, 2017 12:26
Implicit Return (Fat-Arrow)
//Old syntax
var name = function returnName (id) {
return editors[id].name;
}
//Fat-Arrow syntax
var name = id => editors[id].name; //implicit return
@nikkaroraa
nikkaroraa / thisKeyword.js
Created November 26, 2017 15:42
this keyword
function globalFunction() {
console.log(this);
}
globalFunction(); //[object Window]
//globalFunction() is equivalent to window.globalFunction()
var myObj = {name: "obj"};
myObj.logThis = function () {
console.log(this);
@nikkaroraa
nikkaroraa / rebindThisOld.js
Last active November 26, 2017 16:31
Rebind "this" (Old syntax)
//Old syntax
var blog = {
name: 'The School Of JS',
topics: ['DOM', 'JS'],
about: function () {
return this.topics.map(function (topic) {
return topic + ' is a topic of ' + this.name + ' blog!';
});
}
};