Last active
February 4, 2019 01:47
-
-
Save alejandrolechuga/671e65c79b815e23c6f692c2c6a0c1c8 to your computer and use it in GitHub Desktop.
Prototype
This file contains hidden or 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
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