This file contains hidden or 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
//1. | |
var x; | |
x++; | |
console.log(x); | |
//Output:NaN | |
//2. | |
//Check whether a number is NaN with out using isNaN |
This file contains hidden or 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> | |
<head> | |
</head> | |
<body> | |
<script src="lib/yourlib.js"></script> | |
<script> | |
window.onload = function () { | |
EntryPoint.run(); | |
}; | |
</script> |
This file contains hidden or 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
const TIME_OUT = 1000; | |
function start(){ | |
console.log("Before Set-Time-Out"); | |
setTimeout(function(){ | |
console.log("Inside Set-Time-Out","Exiting Set-Time-Out after "+TIME_OUT+" milliseconds"); | |
},TIME_OUT); | |
console.log("Outside Set-Time-Out"); | |
} | |
start(); |
This file contains hidden or 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
const flatten = arr => { | |
let i = 0; | |
while (i < arr.length) { | |
if (Array.isArray(arr[i])) { | |
arr.splice(i, 1, ...arr[i]); | |
} else { | |
i++; | |
} | |
} | |
return arr; |
This file contains hidden or 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
"Before Set-Time-Out" | |
"Outside Set-Time-Out" | |
"Inside Set-Time-Out" -->Would be printed after 1000 milliseconds | |
"Exiting Set-Time-Out after 1000 milliseconds" -->Would be printed after 1000 milliseconds |
This file contains hidden or 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
//TIME_OUT = 0 | |
Expected Output | |
---------------- | |
"Before Set-Time-Out" | |
"Inside Set-Time-Out" | |
"Exiting Set-Time-Out after 0 milliseconds" | |
"Outside Set-Time-Out" | |
Actual Output |
This file contains hidden or 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 multiply(n,n){ | |
return n*n; | |
} | |
function square(n){ | |
return multiply(n,n); | |
} | |
function print(n){ | |
var squared = square(n); |
This file contains hidden or 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
// The classic AJAX call - dispatch before the request, and after it comes back | |
function myThunkActionCreator(someValue) { | |
return (dispatch, getState) => { | |
dispatch({type : "REQUEST_STARTED"}); | |
myAjaxLib.post("/someEndpoint", {data : someValue}) | |
.then( | |
response => dispatch({type : "REQUEST_SUCCEEDED", payload : response}), | |
error => dispatch({type : "REQUEST_FAILED", error : error}) | |
); |
This file contains hidden or 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 noError = true; | |
console.assert(noError,'There is an Error','in the code block'); | |
//Output | |
noError = false; | |
console.assert(noError,'There is an Error','in the code block'); | |
//Output | |
Assertion failed: There is an Error in the code block |
This file contains hidden or 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 counter(label){ | |
console.count(label); | |
} | |
counter('label1'); // label1 : 1 | |
counter('label1'); // label1 : 2 | |
counter('label1'); // label1 : 3 | |
counter('label2'); // label2 : 1 | |
console.count();//1 |
OlderNewer