Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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
You can’t perform that action at this time.