gpt4 book ai didi

javascript - 什么时候需要在 Javascript 中设置类的 'prototype.constructor' 属性?

转载 作者:搜寻专家 更新时间:2023-11-01 04:32:50 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
What it the significance of the Javascript constructor property?

在 Javascript 中 docs在 developer.mozilla.org,关于继承的话题有一个例子

// inherit Person
Student.prototype = new Person();

// correct the constructor pointer because it points to Person
Student.prototype.constructor = Student;

我想知道为什么要在这里更新原型(prototype)的构造函数属性?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com