Discuss / JavaScript / 只有被new的函数才能叫做构造函数

只有被new的函数才能叫做构造函数

Topic source

熠阳0121

#1 Created at ... [Delete] [Delete and Lock User]

function PrimaryStudent(props) {

Student.call(this. props);

}

这里就是单纯的用call把Student的this修正为PrimaryStudent的this然后传参调用,并没有用new Student()所以这里的Student就是一个普通函数,而不应该叫做 构造函数。


  • 1

Reply