var fn1 = function(item) {
console.log('item---', item)
}
var fn = (item) => {
console.log('item---', item)
}
console.log('fn1---', new fn1())
console.log('fn---', new fn())
new fn1() 打印结果
item--- undefined
fn1--- fn1 {}
new fn() 打印结果,箭头函数没有 constructor
Uncaught TypeError: fn is not a constructor
at <anonymous>:8:22
js 箭头函数没有 constructor,不能被new
最新推荐文章于 2024-08-22 17:19:22 发布