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" oninput="makeAPICall()"> | |
<!-- Displays number of time makeAPICall method is called --> | |
<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
var log = console.log | |
log("Inside global execution context") | |
function functionOne() { | |
log("Inside function one") | |
function setTimeoutFunction() { | |
log("Inside setTimeoutFunction: I will be executed atleast after 1 sec") | |
} |
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 timerId = setTimeout(function (){ | |
console.log("This function will be removed before it's executed") | |
}, 100) | |
clearTimeout(timerId) | |
// No output will be displayed as the setTimeout callback function | |
// will be cancelled before it will be executed |
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 multiplyByTwo (num) { | |
console.log(num + " multiplied by 2 is " + num*2) | |
} | |
// Syntax - setTimeout(callbackMethod, delay, param1, param2, ..) | |
setTimeout(multiplyByTwo, 100, 4) | |
// Output: | |
// 4 multiplied by 2 is 8 |