Skip to content

Instantly share code, notes, and snippets.

@teovoinea
Created November 24, 2017 15:24
Show Gist options
  • Save teovoinea/13fea81f829370d0f697e50bbab27a32 to your computer and use it in GitHub Desktop.
Save teovoinea/13fea81f829370d0f697e50bbab27a32 to your computer and use it in GitHub Desktop.
var foo = {
a: 1
};
var bar = {
a: 2,
b: "bar"
};
function X() {
console.log("a is " + this.a);
}
function Y() {
console.log("a is " + this.a);
console.log("b is " + this.b);
}
X.call(foo); // a is 1
X.call(bar); // a is 2
Y.call(bar); // a is 2 \n b is bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment