I copied most of the code from an MDN article on .create()
with some slight modification:
// superclass
function Shape() {
this.x = 0;
this.y = 0;
};
// superclass method
Shape.prototype.move = function( x, y ) {
this.x += x;
this.y += y;
console.info('Shape moved.');
};
// subclass
function Rectangle() {
Shape.call(this); // call super constructor passing the current object
}
Rectangle.prototype = Object.create( Shape.prototype );
var rect = new Rectangle();
console.log( rect.move( 1, 1 ) );
Output:
Shape moved
undefined
Why is it getting undefined
also?