Skip to content

Instantly share code, notes, and snippets.

@conanak99

conanak99/objCreating.js Secret

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