Skip to content

Instantly share code, notes, and snippets.

@felixge
Created September 29, 2011 08:51
Show Gist options
  • Save felixge/1250329 to your computer and use it in GitHub Desktop.
Save felixge/1250329 to your computer and use it in GitHub Desktop.
Showing that this keyword is referencing executing context
red
red
green
yellow
red
blue
red
green
yellow
red
var color = 'blue';
this.color = 'red';
console.log( color ); // blue
console.log( this.color ); // red
(function ( global ){
var color = 'green';
this.color = 'yellow';
console.log( color ); // green
console.log( this.color ); // yellow
console.log( global.color ); // red
}( this ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment