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