Created
January 7, 2016 17:43
-
-
Save conanak99/d7e6c4c90079837c74aa 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', | |
friends : ['Minh', 'Sang', 'Khoa', 'Hoang'], | |
showFriend: function() { | |
for(var i = 0; i < this.friends.length; i++) | |
console.log(this.firstName + ' have a friend named ' + this.friends[i]); | |
}, | |
showFriendThis: function() { | |
this.friends.forEach(function(fr){ | |
console.log(this.firstName + ' have a friend named ' + fr); | |
}); | |
} | |
}; | |
person.showFriend(); //Hàm chạy đúng | |
person.showFriendThis(); // Hàm chạy sai |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment