Skip to content

Instantly share code, notes, and snippets.

View jawache's full-sized avatar

Asim Hussain jawache

View GitHub Profile
// What happens when you execute the code below
a = 1;
// What does the below code print out?
console.log(this);
// What does the below code print out?
"use strict";
(function (){
console.log(this);
})();
// What does the below code print out?
"use strict";
var animal = {
kind: "Cow",
which: function () {
console.log(this.kind);
}
};
animal.which();
// What does the below code print out?
"use strict";
var animal = {
kind: "Cow",
which: function () {
console.log(this.kind);
}
};
// What does the below code print out?
"use strict";
function sayHello(last_name) {
console.log("Hello " + this + " " + last_name);
}
sayHello("Hussain");
// What does the below code print out?
"use strict";
function sayHello(last_name) {
console.log("Hello " + this + " " + last_name);
}
sayHello.call("Asim", "Hussain");
// What does the below code print out?
"use strict";
function sayHello(last_name) {
console.log("Hello " + this + " " + last_name);
}
sayHello.apply("Asim", ["Hussain"]);
// What does the below code print out?
"use strict";
function sayHello(last_name) {
console.log("Hello " + this + " " + last_name);
}.bind("Asim");
sayHello("Hussain");
// What does the below code print out?
"use strict";
var sayHello = function(last_name) {
console.log("Hello " + this + " " + last_name);
}.bind("Asim");
sayHello("Hussain");