-
-
Save conanak99/2668c8e27045d12f9cc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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