← 返回完整题库
JavaScript简单

箭头函数可以用 new 吗?

参考答案

不能。new (() => {})() 抛 TypeError: xxx is not a constructor。

原因:

  1. 箭头函数没有 [[Construct]] 内部方法;
  2. 没有 prototype 属性((()=>{}).prototype === undefined);
  3. this 由词法决定,无法绑定到新实例;
  4. 没有 new.target、arguments、super。

如需构造能力用普通函数或 class。

本题来自 计算机知识面试题库,共 921 道题。