Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created January 13, 2016 15:04
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/2668c8e27045d12f9cc0 to your computer and use it in GitHub Desktop.
Save conanak99/2668c8e27045d12f9cc0 to your computer and use it in GitHub Desktop.
// Cách 1 : Object literal
// Khai báo toàn bộ các trường và hàm
var person = {
firstName: 'Hoang',
lastName: 'Pham',
showName: function() {
console.log(this.firstName + ' ' + this.lastName);
}
};
// Cách 2 : Object constructor
var psn = new Object();
psn.firstName = 'Hoang';
psn.lastName = 'Pham';
psn.showName = function() {
console.log(this.firstName + ' ' + this.lastName);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment