Prototypal inheritance in JavaScript

后端 未结 4 1819
不知归路
不知归路 2021-02-03 13:31

I\'ve been watching Douglas Crockford\'s talks at YUI Theater, and I have a question about JavaScript inheritance...

Douglas gives this example to show that \"Hoozit\" i

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-03 14:06

    In addition to Triptych's answer: Hoozit instances will also inherit all instance properties of Gizmo, not only the ones defined in the prototype; eg:

    function Gizmo() {
        this.foo = 'bar'; // foo is visible in every Hoozit instance
    }
    

提交回复
热议问题