Q:

Understand Object.create

After reading the Object.create document. I did some test for it .
Here is my code . please review it.
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);

Rectangle.move(); //?? why move function is not found ?

As the document says Object.create(proto[,propertiesObject]); proto should be the prototype of the newly-created object.
So, Rectangle.prototype should be equal with the Shape. but actually it is not. Apparently I didn't understand this part of document. and I still found Rectangle.__proto__==Shape is true. OK, Even Rectangle.__proto__==Shape is true , Why Rectangle can't find the move function? Is the move function not in the prototype chain?? I thought the move function is in the Rectangle.__proto__.prototype, It supposed to be found in the chain. Why can not? thanks.

A:

The prototype must be an actual object.  In this case, you should pass Shape's prototype, not the Shape function.
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.prototype, {a:1});

Rectangle.move(); // it will call now
Rectangle.a; // 1
Rectangle.x; // NaN ???
Rectangle.y; // NaN ???

Note that Object.create() is not the same as using the new keyword - that might be what you were looking for instead.
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=new Shape;

Rectangle.move(1,2); // works properly now
Rectangle.a; // undefined, we never made one
Rectangle.x; // 1
Rectangle.y; // 2

As Javascript actually looks up the constructor and its .prototype to find the prototype recursively, it won't look up Shape's prototype as it was not directly set nor was the new constructor used to create Rectangle:
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);
Rectangle.constructor; // Function()
Rectangle.constructor.prototype; // That's Function.prototype
/* as you can see Shape.prototype is never touched by the prototype chain */

Rectangle.__proto__; // Shape(), not the prototype (doesn't have any direct properties on it)

Rectangle.move(1,2); // TypeError: Rectangle.move is not a function
Rectangle.a; // does not exist
Rectangle.x; // function never called on Rectangle, so also doesn't exist
Rectangle.y; // function never called on Rectangle, so also doesn't exist

