Skip to content

Instantly share code, notes, and snippets.

@knd
Last active December 11, 2015 01:28
Show Gist options
  • Save knd/4523269 to your computer and use it in GitHub Desktop.
Save knd/4523269 to your computer and use it in GitHub Desktop.
function invocation
function cook() {
console.log(this); // 'this' is 'Window'
// the default global object of Chrome
function prepare() {
console.log(this); // 'this' is also 'Window'
}
prepare();
}
var cook101 = function() {
console.log(this); // 'this' is 'Window'
var prepare101 = function() {
console.log(this); // 'this' is 'Window'
}
prepare101();
}
cook(); // direct invocation
prepare101(); // direct invocation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment