Skip to content

Instantly share code, notes, and snippets.

@alejandrolechuga
Last active February 4, 2019 01:47
Show Gist options
  • Save alejandrolechuga/671e65c79b815e23c6f692c2c6a0c1c8 to your computer and use it in GitHub Desktop.
Save alejandrolechuga/671e65c79b815e23c6f692c2c6a0c1c8 to your computer and use it in GitHub Desktop.
Prototype
function Book(name, year) {
// propiedades
this.name = name;
this.year = year;
}
// metodos
Book.prototype.getName = function () {
return this.name;
};
Book.prototype.getYear = function () {
return this.year;
};
var libro = new Book('Don quijote', 1612);
var libro2 = new Book('Movy dick', 1920);
// comparamos metodos
libro.getName === libro2.getName; // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment