Skip to content

Instantly share code, notes, and snippets.

@conanak99
Last active January 7, 2016 18:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conanak99/5d3759f726ab25802374 to your computer and use it in GitHub Desktop.
Save conanak99/5d3759f726ab25802374 to your computer and use it in GitHub Desktop.
var person = {
firstName: 'Hoang',
lastName: 'Pham',
showName: function() {
console.log(this.firstName + ' ' + this.lastName);
}
};
var showNameFunc = person.showName.bind(person); //Gán function vào biến showNameFunc
showNameFunc(); //Chạy đúng vì this bây giờ là object person, do ta đã bind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment