super test
JavaScript
var Food = function( name ){
this.name = name;
}
Food.prototype.sayName = function(){
console.log( 'I am a ' + this.name );
}
var Fruit = function( name, color ){
Food.call( this, name );
this.color = color;
this.super = Object.getPrototypeOf( Object.getPrototypeOf( this ) );
}
Fruit.prototype = Object.create( Food.prototype );
Fruit.prototype.sayName = function(){
console.log( 'I am a fruit and I am the color ' + this.color );
}
var orange = new Fruit( 'apple', 'red' );
// runs the overridden method in orange
orange.sayName(); // I am a fruit and I am the color red
// runs the super method
orange.super.sayName.call( orange ); // I am a apple