class Mammalia
{
constructor()
{
this['class'] = 'Mammalia';
this.species = 'Unknown';
}
getClass()
{
return this['class'];
}
}
class Human extends Mammalia
{
constructor( name = 'Some human' )
{
const x = 1;
super();
this.name = name;
this.species = 'Homo sapiens';
}
sayName()
{
console.log( 'My name is ' + this.name );
}
getClass()
{
return super.getClass() + ', ' + this.species;
}
}
const Human2 = class extends Mammalia
{
sayName()
{
console.log( 'I don\'t know' );
}
};
const Human3 = class Human extends Mammalia
{
static some()
{
return 42;
}
other()
{
return Human.some();
}
}
Created
May 25, 2017 10:50
-
-
Save koyta/ef61f759ca481772d67fbf38cbaf8b85 to your computer and use it in GitHub Desktop.
Human - наследование
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment