学东西总是不够坚持、深入

F.prototype

这里的就是意味着常规的property。

其实就是只要有新的obj被创造,就会自动赋予它animal的[[prototype]].

每个function都有“prototype”的property,即使我们没有赋予他们,default “prototype”。

默认F.prototype就是constructor:自己

这种“prototype” property只能在设置constructor并且invoke with new。

regular obj里面就没有魔法。

Native prototypes

就算是创建空obj,也是有指向[[prototype]]。

Borrowing from prototype

这里讲的是从一个obj里面借method到另一个obj。

一般借一些原生prototype,比如说如果我们创建一个array-like obj,我们像借一些array methods。

因为built-in join method不会在乎是不是array,而只在乎正确的indexes和length。

还有一种是obj._proto_ = Array.prototype,所有的methods都会被复制过去。

我们只能一次inherit from one obj。

你可能感兴趣的:(学东西总是不够坚持、深入)