var person = { | |
firstName: 'Hoang', | |
lastName: 'Pham', | |
50: 'Hi', // Property có tên là số, không dùng dotNotation được | |
showName: function() { | |
console.log(this.firstName + ' ' + this.lastName); | |
} | |
}; | |
console.log(person.firstName); // Hoang | |
console.log(person['firstName']); // Hoang | |
console.log(person.50); // Bị lỗi | |
console.log(person['50']); // Hi | |
console.log(person.showName()); // Hoang Pham | |
console.log(person['showName']()); // Hoang Pham |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment