Skip to content

Instantly share code, notes, and snippets.

@zootella
Created July 11, 2014 07:24
Show Gist options
  • Save zootella/5fb5026f4df24c9a0068 to your computer and use it in GitHub Desktop.
Save zootella/5fb5026f4df24c9a0068 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";
}
set2();
set3(this);
set4.call(this);
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment