Seems I didn't understand the constructor concept, So, I wrote some code to test it. Say you have the code like this:
var test=function(){...} I know there is a property named constructor in the test.prototype object which point to the test object.
Here comes my question:
Is this property(constructor) only belongs to the prototype object ? or Do all the objects have the constructor property?
And I did another test. the code like below:
function Shape() { this.x = 0; this.y = 0; } Shape.prototype.move = function(x, y) { this.x += x; this.y += y; console.info("Shape moved."); }; Rectangle = Object.create(Shape);//inherit from the Shape instead of Shape.prototype Rectangle.constructor==Function//it is true. I don't know where does Rectangle.constuctor come from or does it inherit from the Shape? thanks.