Last active
July 18, 2018 23:53
-
-
Save caiogranero/c15ac829c7cb25745d5a22b7c21615a1 to your computer and use it in GitHub Desktop.
Classes com ECMA6
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
class User { | |
constructor(firstName, lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
getFullName() { | |
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