Skip to content

Instantly share code, notes, and snippets.

@conanak99
Last active January 18, 2016 17:47
Show Gist options
  • Save conanak99/18b5d6f0391ddbdd962d to your computer and use it in GitHub Desktop.
Save conanak99/18b5d6f0391ddbdd962d to your computer and use it in GitHub Desktop.
var person = {
firstName: 'Hoang',
lastName: 'Pham',
showName: function() {
console.log(this.firstName + ' ' + this.lastName);
}
}; // object này có prototype là Object.prototype
function Person(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.showName = function() {
console.log(this.firstName + ' ' + this.lastName);
};
}
var otherPerson = new Person('Hoang', 'Pham'); // object này có prototype là Person.prototype
// Prototype mới: Person.prototype được tạo ra
// Person.prototype kế thừa Object.prototype
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment