Skip to content

Instantly share code, notes, and snippets.

@sevperez
Created June 9, 2018 16:03
Show Gist options
  • Select an option

  • Save sevperez/04259e5e671d581ccacea782598d7da4 to your computer and use it in GitHub Desktop.

Select an option

Save sevperez/04259e5e671d581ccacea782598d7da4 to your computer and use it in GitHub Desktop.
// option 1
var theater = {
playMovie: function(movie, previewLength) {
this.loadProjector(movie);
setTimeout(function() {
console.log("Now playing: " + this.movie);
}.bind(this), previewLength);
}
}
// option 2
var theater = {
playMovie: function(movie, previewLength) {
var self = this;
this.loadProjector(movie);
setTimeout(function() {
console.log("Now playing: " + self.movie);
}, previewLength);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment