Created
June 30, 2017 10:28
-
-
Save Shwartz/6b8ce378a735cc9a760513a7075b942e to your computer and use it in GitHub Desktop.
sub class experiment
This file contains 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
(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