Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var person = {
firstName: 'Hoang',
lastName: 'Pham',
friends : ['Minh', 'Sang', 'Khoa', 'Hoang'],
showFriendFixed: function() {
var personObj = this; //Gán giá trị this vào biến personObj
this.friends.forEach(function(fr){
console.log(personObj.firstName + ' have a friend named ' + fr);
});
}
};
person.showFriendFixed(); //Hàm chạy đúng
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.