Skip to content

Instantly share code, notes, and snippets.

@caiogranero
Last active July 18, 2018 23:53
Show Gist options
  • Save caiogranero/7c35844138f1eae23b7e51e0129f5f82 to your computer and use it in GitHub Desktop.
Save caiogranero/7c35844138f1eae23b7e51e0129f5f82 to your computer and use it in GitHub Desktop.
Classes com Prototype
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