Skip to content

Instantly share code, notes, and snippets.

@tiagopog
Created May 19, 2015 03:58
Show Gist options
  • Save tiagopog/693cfcd69fddda3b800d to your computer and use it in GitHub Desktop.
Save tiagopog/693cfcd69fddda3b800d to your computer and use it in GitHub Desktop.
JavaScript ES6
// Old way...
function Person(name) {
this._name = name;
};
Person.prototype.getName = function() {
return this._name;
};
person = new Person('Foo');
console.log(person.getName());
// New way...
class Person {
constructor(name) {
this._name = name;
}
getName() {
return this._name;
}
}
person = new Person('Bar');
console.log(person.getName());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment