Last active
May 28, 2018 10:13
-
-
Save completejavascript/54c0af922d3a644b525fbf84f23f2333 to your computer and use it in GitHub Desktop.
Fun quiz!!
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
let arr = [1, "hi", {x : 2}, [3, 4]]; | |
delete arr[1]; | |
console.log(arr.length); | |
// What will console print? |
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
let arr = [1, "hi", {x : 2}, [3, 4]]; | |
for(let i = 0; i < arr.length; i++) { | |
if (arr[i] === "hi") arr.splice(i, 1); | |
else console.log(arr[i]); | |
} | |
// What will console print? |
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; | |
var z = y + 3; | |
var y = 2; | |
console.log(x, y, z); | |
// What will console print? |
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
"use strict"; | |
function func() { | |
return this; | |
} | |
console.log(func()); | |
// What will console print? |
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 Foo() { | |
this.bar = 10; | |
} | |
Foo.prototype.bar = 42; | |
var foo = new Foo(); | |
console.log("1", foo.bar); | |
delete foo.bar; | |
console.log("2", foo.bar); |
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
let a = (function(x, y, z){ | |
delete x, delete y, delete z; | |
return x + y + z; | |
})(1, [2, 3], {x: 4}); | |
console.log(a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment