Skip to content

Instantly share code, notes, and snippets.

@nikkaroraa
Last active November 26, 2017 16:31
Show Gist options
  • Save nikkaroraa/d4929e155657b7a9b6bb26b14feb36bf to your computer and use it in GitHub Desktop.
Save nikkaroraa/d4929e155657b7a9b6bb26b14feb36bf to your computer and use it in GitHub Desktop.
Rebind "this" (Old syntax)
//Old syntax
var blog = {
name: 'The School Of JS',
topics: ['DOM', 'JS'],
about: function () {
return this.topics.map(function (topic) {
return topic + ' is a topic of ' + this.name + ' blog!';
});
}
};
blog.about();
//["DOM is a topic of blog!", "JS is a topic of blog!"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment