Skip to content

Instantly share code, notes, and snippets.

@anacampesan
Created June 19, 2018 14:52
Show Gist options
  • Save anacampesan/37ab6f518542d3bb8c2e0cac2fcc59d7 to your computer and use it in GitHub Desktop.
Save anacampesan/37ab6f518542d3bb8c2e0cac2fcc59d7 to your computer and use it in GitHub Desktop.
let animal = {
init: function(name, age) {
this.name = name;
this.age = age;
return this;
},
getName: function() {
return this.name;
},
getAge: function() {
return this.age;
}
}
let human = Object.create(animal).init('Ana', 24);
console.log(human.getAge());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment