JingchaoZhao / js-learning

knowledge of webs
0 stars 0 forks source link

6. prototype #9

Closed JingchaoZhao closed 5 years ago

JingchaoZhao commented 5 years ago

function Foo(name) { this.name = name } Foo.prototype.myName = function () { return this.name } function Bar (name, label) { Foo.call(this, name); this.label = label } Bar.prototype = Object.create(Foo.prototype) Bar.prototype.myLabel = function () { return this.label }