Skip to content

Instantly share code, notes, and snippets.

@1dolinski
Created June 20, 2016 14:15
Show Gist options
  • Select an option

  • Save 1dolinski/8e531f2b17d2910587626bf8a3726ec4 to your computer and use it in GitHub Desktop.

Select an option

Save 1dolinski/8e531f2b17d2910587626bf8a3726ec4 to your computer and use it in GitHub Desktop.
var test = {
result: "result",
zero: function() {
return this.result;
},
one: function() {
return test.result;
},
two: () => {
return this.result;
},
three: () => {
return test.result;
}
}
console.log(test["zero"]()); // #=> result
console.log(test["one"]()); // #=> result
console.log(test["two"]()); // #=> undefined
console.log(test["three"]()); // #=> result
// How can I use 'this', in test["two"]()?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment