This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = [1, 2, 3, 4] | |
for (var ai = 0; ai < a.length; ai++) { | |
setTimeout(function(){ | |
// By the time this code will be executed, all the iterations of | |
// for loop would have completed and value of ai would be 4 | |
console.log("Value of 'ai': " + ai) | |
}, 1000) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<style> | |
div { | |
border: 1px solid black; | |
width: 300px; | |
height: 200px; | |
overflow: scroll; | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<label>Search</label> | |
<!-- Renders an HTML input box --> | |
<input type="text" id="search-box"> | |
<p>No of times user actually clicked</p> | |
<p id='show-api-call-count'></p> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<label>Search</label> | |
<!-- Renders an HTML input box --> | |
<input type="text" id="search-box"> | |
<p>No of times user actually clicked</p> | |
<p id='show-api-call-count'></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function delayFuncExec() { | |
// This statement will not be printed as it will be cancelled by | |
// clearTimeout | |
console.log("I will not be executed as I will be cancelled"); | |
} | |
var timerId = setTimeout(delayFuncExec, 100) | |
console.log("Timer Id: " + timerId) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<button id="click-btn">Click me!</button> | |
</body> | |
<script> | |
var timerId; | |
var clickBtn = document.getElementById('click-btn'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function delayFuncExec () { | |
console.log("I will be called after every 100 milliseconds"); | |
} | |
var timerId = setInterval(delayFuncExec, 100) | |
console.log("Timer Id: " + timerId) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function delayFuncExec() { | |
console.log("I will be called after 100 milliseconds"); | |
} | |
var timerId = setTimeout(delayFuncExec, 100) | |
console.log("Timer Id: " + timerId) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<button id="click-btn">Click me!</button> | |
</body> | |
<script> | |
var timerId; | |
var clickBtn = document.getElementById('click-btn'); | |
var clickFunction = function(){ |
NewerOlder