Skip to content

Instantly share code, notes, and snippets.

@conanak99
Last active March 9, 2016 00:51
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/cb8029be09054bdf35de to your computer and use it in GitHub Desktop.
Save conanak99/cb8029be09054bdf35de to your computer and use it in GitHub Desktop.
var firstName = 'Hoang';
var lastName = 'Pham';
// Khai báo object kiểu cũ
var obj = {
firstName: firstName,
lastName: lastName,
showName: function() { console.log(this.firstName + ' ' + this.lastName) }
};
// Khai báo kiểu mới, ngắn gọn hơn
// Không cần lặp lại tên biến hay function
var obj = {
firstName,
lastName,
showName() { console.log(this.firstName + ' ' + this.lastName) }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment