Skip to content

Instantly share code, notes, and snippets.

@zootella
Created July 11, 2014 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zootella/da7f7b1bb85eb2af3a0f to your computer and use it in GitHub Desktop.
Save zootella/da7f7b1bb85eb2af3a0f to your computer and use it in GitHub Desktop.
var color1 = "red";
function set2() {
this["color2"] = "orange";
}
function set3(destination) {
destination["color3"] = "yellow";
}
function set4() {
this["color4"] = "green";
}
function getThis() { return this; }
function set5(f) {
var t = f();
t["color5"] = "blue";
}
set2();
set3(this);
set4.call(this);
set5(getThis);
console.log(color1);//works
console.log(color2);//works
//console.log(color3);//doesn't work, color3 is undefined
//console.log(color4);//doesn't work, color4 is undefined
console.log(color5);//works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment