Skip to content

Instantly share code, notes, and snippets.

@mattn9x
Created July 2, 2017 06:56
Show Gist options
  • Save mattn9x/7ce1206c02b7f621490ca9d44316b0af to your computer and use it in GitHub Desktop.
Save mattn9x/7ce1206c02b7f621490ca9d44316b0af to your computer and use it in GitHub Desktop.
Khởi tạo đối tượng với prototype
function Student() {}
Student.prototype.firstName = "Manh"; Student.prototype.lastName = "Nguyen";
Student.prototype.showName = function () {
console.log("I'm " + this.firstName + '- ' + this.lastName);
};
var student = new Student();
console.log('Test Protoype'); console.log(student.firstName);// Manhstudent.showName(); //I'm Manh- Nguyen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment