首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

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

2012-11-22 
犀牛书第五版读书笔记——Chapter 9. Classes, Constructors, and Prototypes(第二部分)8.当在Complex对象上

犀牛书第五版读书笔记——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()构造函数创建的。

热点排行