Javascript examples for Object:prototype
Rectangle extending Shape
function Shape() { this.x = 0//www . java 2 s . c o m this.y = 0 } Shape.prototype.move = function(x, y) { this.x += x this.y += y console.info('Shape moved.') } // Rectangle - ??(subclass) function Rectangle() { Shape.call(this) // call super constructor. } Rectangle.prototype = Object.create(Shape.prototype) // Rectangle.prototype.constructor = Rectangle var rect = new Rectangle() console.log(rect)