我有如下箭头功能:
var Test = () => {}
我打电话的时候:
new Test()
我回来了:
VM110:1 Uncaught TypeError: Test is not a constructor(…)(anonymous function) @ VM110:1
我们无法在箭头功能上调用new
吗?
答案 0 :(得分:1)
箭头函数不能用作构造函数:普通函数通过内部方法[[Construct]]和属性原型支持new。箭头功能都没有,这就是为什么
new (() => {})
抛出错误。