犀牛书第五版读书笔记——Chapter 9. Classes, Constructors, and Prototypes(第二部分)

8.当在Complex对象上查找属性时,首先在对象本身上查找。如果属性没有找到,就查找Complex.prototype对象。最后,如果仍然没有找到,则在Object.prototype对象上查找

9.在需要的时候,用以下方式可以实现从任何对象继承,而不只是从Object类继承
PositionedRectangle.prototype = new Rectangle( );
delete PositionedRectangle.prototype.width;
delete PositionedRectangle.prototype.height;
PositionedRectangle.prototype.constructor = PositionedRectangle;


10.typeof null == "object",而typeof undefined == "undefined"

11.判断一个对象的类型,有typeof,instanceof,constructor等多种方法

12.鸭子类型:如果一个对象拥有类X定义的所有属性,那么就可以将该对象看做是类X的一个实例,无论它是不是用X()构造函数创建的。

你可能感兴趣的:(prototype,读书)