Skip to content

Instantly share code, notes, and snippets.

@BolajiAyodeji
Last active March 3, 2019 20:11
Show Gist options
  • Save BolajiAyodeji/bb8f895b853439b51f987465f8f9762f to your computer and use it in GitHub Desktop.
Save BolajiAyodeji/bb8f895b853439b51f987465f8f9762f to your computer and use it in GitHub Desktop.
The This Keyword
// method (function inside an object) -> object
// function -> global (window, global)
const video = {
title: 'Bird Box',
tags: ['english', 'french', 'chineese'],
showTags() {
this.tags.forEach(tag => {
console.log(this.title, tag);
});
}
}
video.showTags();
// function playVideo () {
// console.log(this);
// }
// playVideo.call({ name: 'Bolaji'});
// playVideo.apply({ name: 'Bolaji'});
// playVideo.bind({ name: 'Bolaji'}) ();
// playVideo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment