Last active
July 18, 2018 23:53
-
-
Save caiogranero/7c35844138f1eae23b7e51e0129f5f82 to your computer and use it in GitHub Desktop.
Classes com Prototype
This file contains 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 User(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
User.prototype.getFullName = function() { | |
console.log(this.firstName + " " + this.lastName); | |
}; | |
var user = new User("Jon", "Snow"); | |
user.getFullName(); //"Jon Snow" | |
console.log(user instanceof User); // true | |
console.log(user instanceof Object); // true | |
console.log(typeof(User)); // function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment