Discuss / JavaScript / 为什么不同情况下new F()后得到的赋值不同?

为什么不同情况下new F()后得到的赋值不同?

Topic source

hahaxtu

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

为什么F()单独调用和给变量赋值时的返回值与PrimaryStudent.prototype=new F()时的返回值不一样?

new F();//F {}
var b=new F();//undefined
b;//F {}
PrimaryStudent.prototype=new F();//Student {}
PrimaryStudent.prototype;//Student {}

  • 1

Reply