Skip to content

Instantly share code, notes, and snippets.

@completejavascript
Last active May 28, 2018 03:50
Show Gist options
  • Save completejavascript/f68d5dbcede5654c399611c29d61523a to your computer and use it in GitHub Desktop.
Save completejavascript/f68d5dbcede5654c399611c29d61523a to your computer and use it in GitHub Desktop.
Fun quiz!!!
Object.prototype.objCustom = function() {};
Array.prototype.arrCustom = function() {};
let a = [3, 5, 7];
a.x = 'hello';
Object.defineProperty(a, 'y', {});
Object.defineProperty(a, 'z', {
enumerable: true
});
for (let i of a) {
console.log(i);
}
// What will console print?
Object.prototype.objCustom = function() {};
Array.prototype.arrCustom = function() {};
let a = [3, 5, 7];
a.x = 'hello';
Object.defineProperty(a, 'y', {});
Object.defineProperty(a, 'z', {
enumerable: true
});
for (let i in a) {
console.log(i);
}
// What will console print?
Object.prototype.objCustom = function() {};
Array.prototype.arrCustom = function() {};
let a = [3, 5, 7];
a.x = 'hello';
Object.defineProperty(a, 'y', {});
Object.defineProperty(a, 'z', {
enumerable: true
});
for (let i in a) {
if (a.hasOwnProperty(i)) console.log(i);
}
// What will console print?
let obj = {
x: 1,
y: "hello",
z: {a : 1},
t: [1, 2]
};
Object.freeze(obj);
obj.x = 2;
obj.y = "bye";
obj.z.a = 2;
obj.t[0] = 3;
obj.t[1] = 4;
console.log(obj);
// What will console print?
let obj = {
x : 1,
y : "Hi",
z : function() {
console.log(this.x, this.y);
}
};
let str = JSON.stringify(obj);
console.log(str);
// What will console print?
let a = {y: 1};
a.x = a;
let str = JSON.stringify(a);
console.log(str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment