Skip to content

Instantly share code, notes, and snippets.

@conanak99

conanak99/notation.js Secret

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