Skip to content

Instantly share code, notes, and snippets.

@Shwartz
Created June 30, 2017 10:28
Show Gist options
  • Save Shwartz/6b8ce378a735cc9a760513a7075b942e to your computer and use it in GitHub Desktop.
Save Shwartz/6b8ce378a735cc9a760513a7075b942e to your computer and use it in GitHub Desktop.
sub class experiment
(function () {
const subClassExample = {
Person: function(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.gender = 'male';
}
}
const clark = new subClassExample.Person('Clark', 'Kent');
subClassExample.SuperHero = function(firstName, lastName, powers) {
subClassExample.Person.call(this, firstName, lastName);
this.powers = powers;
}
const superman = new subClassExample.SuperHero('Clark', 'Kent', ['flight']);
console.log('subClassExample', subClassExample);
console.log('superman', superman);
})();
' ----- end ----- ';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment