Created
January 7, 2016 17:54
-
-
Save conanak99/452b24d53a634a48777f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var person = { | |
firstName: 'Hoang', | |
lastName: 'Pham', | |
showName: function() { | |
console.log(this.firstName + ' ' + this.lastName); | |
} | |
}; | |
//Ở đây this sẽ là object person, chạy đúng | |
person.showName(); //Hoang Pham. | |
var showNameFunc = person.showName; //Gán function vào biến showNameFunc | |
showNameFunc(); //Chạy sai, ở đây this sẽ là object window |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment