Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Last active May 28, 2018 10:13
Show Gist options
  • Save completejavascript/54c0af922d3a644b525fbf84f23f2333 to your computer and use it in GitHub Desktop.
Save completejavascript/54c0af922d3a644b525fbf84f23f2333 to your computer and use it in GitHub Desktop.
Fun quiz!!
let arr = [1, "hi", {x : 2}, [3, 4]];
delete arr[1];
console.log(arr.length);
// What will console print?
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?
var x = 1;
var z = y + 3;
var y = 2;
console.log(x, y, z);
// What will console print?
"use strict";
function func() {
return this;
}
console.log(func());
// What will console print?
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);
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