Javascript构造函数属性的意义是什么?
constructorconstructor
function Foo(age) {
this.age = age;}function Bar() {
Foo.call(this, 42);
this.name = "baz"; }Bar.prototype = Object.create(Foo.prototype); var b = new Bar; alert(b.constructor);
// "Foo". That's OK because we inherit `Foo`'s prototype.alert(b.name);
// "baz". Shows that Bar() was called as constructor.alert(b.age);
// "42", inherited from `Foo`.bBarFoo
Bar.prototype.constructor = Bar;
Barb
慕尼黑8549860
慕的地8271018
蓝山帝景
随时随地看视频慕课网APP
相关分类