Last active
August 27, 2020 16:43
-
-
Save csim/2fb35099a926b66bc0072cece58ec73b to your computer and use it in GitHub Desktop.
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
// Please name the data types available JavaScript. |
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
console.log("---- Block 1 ---------------------------------------------"); | |
try { | |
function function1() { | |
var x1 = 1; | |
console.log(typeof x1); | |
console.log(x1); | |
} | |
function1(); | |
console.log(typeof x1); | |
console.log(x1); | |
} catch (e) { | |
console.error(e); | |
} | |
// What is printed to the console at this point? | |
console.log("---- Block 2 ---------------------------------------------"); | |
try { | |
var x2; | |
function function2() { | |
x2 = 2; | |
console.log(typeof x2); | |
console.log(x2); | |
} | |
function2(); | |
console.log(typeof x2); | |
console.log(x2); | |
} catch (e) { | |
console.error(e); | |
} | |
// What is printed to the console at this point? | |
console.log("---- Block 3 ---------------------------------------------"); | |
try { | |
function function3() { | |
if (true) { | |
let x3 = 3; | |
console.log(typeof x3); | |
console.log(x3); | |
} | |
console.log(typeof x3); | |
console.log(x3); | |
} | |
function3(); | |
console.log(typeof x3); | |
console.log(x3); | |
} catch (e) { | |
console.error(e); | |
} | |
// What is printed to the console at this point? |
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 x = 1; | |
console.log(x == 1); | |
console.log(x === 1); | |
console.log(x == "1"); | |
console.log(x === "1"); | |
// What is logged to the console? |
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 obj1 = { | |
function1: function() { | |
console.log(this); | |
console.log(typeof this); | |
console.log(this === obj1); | |
} | |
} | |
obj1.function1(); | |
obj1.function1.call({ x1: 1 }); | |
// What is logged to the console? |
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
const arr = [10, 12, 15, 21]; | |
for (var i = 0; i < arr.length - 1; i++) { | |
var timeout = setTimeout(function() { | |
console.log(`Index: ${i}, element: ${arr[i]}`); | |
}, 1000); | |
} | |
// What is logged to the console? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment