看不懂其中一行:
// The constructor function initializes those properties that
// will be different for each instance.
function Rectangle(w, h) {
this.width = w;
this.height = h;
}
// The prototype object holds methods and other properties that
// should be shared by each instance.
Rectangle.prototype.area = function( ) { return this.width * this.height; }
var r = new Rectangle(2, 3);
r.hasOwnProperty("width"); // true: width is a direct property of r
r.hasOwnProperty("area");
// false: area is an inherited property of r
——这里
"area" in r;
// true: "area" is a property of r
为什么说“r.hasOwnProperty("area");
// false: area is an inherited property of r”,会返回一个false值?
二楼的大虾,说说由于prototype的理由撒。