Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created January 13, 2016 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conanak99/1314a76dabe361f9fc05 to your computer and use it in GitHub Desktop.
Save conanak99/1314a76dabe361f9fc05 to your computer and use it in GitHub Desktop.
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