Skip to content

Instantly share code, notes, and snippets.

@conanak99

conanak99/prototype.js Secret

Last active Jan 13, 2016
Embed
What would you like to do?
function Person() {}
Person.prototype.firstName = 'Hoang';
Person.prototype.lastName = 'Pham';
Person.prototype.showName = function() {
console.log(this.firstName + ' ' + this.lastName);
};
// Object được tạo sẽ có sẵn các trường firstName, lastName
// và hàm showName
var psn1 = new Person();
console.log(psn1.firstName); //Hoang
psn1.showName; //Hoang Pham
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.