javascript - ES2015 规范附录 E 中的此条目有何意义?

标签 javascript ecmascript-6

ES2015 规范的附录 E 包含以下内容:

19.2.3.2: In ECMAScript 2015, the [[Prototype]] internal slot of a bound function is set to the [[GetPrototypeOf]] value of its target function. In the previous edition, [[Prototype]] was always set to %FunctionPrototype%.

这有什么意义?

来源:http://www.ecma-international.org/ecma-262/6.0/#sec-additions-and-changes-that-introduce-incompatibilities-with-prior-editions

最佳答案

在 ES2015 之前,只有单一类型的函数。 ES2015介绍了箭头函数、生成器函数和方法。生成器函数和方法不一定以Function.prototype作为其原型(prototype)。例如:

9.2.6 GeneratorFunctionCreate (kind, ParameterList, Body, Scope, Strict)

  1. Let functionPrototype be the intrinsic object %Generator%.
  2. Let F be FunctionAllocate(functionPrototype, Strict, "generator").
  3. Return FunctionInitialize(F, kind, ParameterList, Body, Scope).

这些函数的绑定(bind)版本可能应该“保留”原始函数的原型(prototype)。

关于javascript - ES2015 规范附录 E 中的此条目有何意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44420105/

相关文章:

javascript - 多次调用子组件构造函数

javascript - 如何导入文件以及如何在需要的地方调用它

javascript - webpack 4 和 babel 7 出错

c# - ASP.NET - 文件下载后如何回发页面?

javascript - HTML 元素无法在 Samsung Tab Active2 Tablet 上的 chrome 中正确打开

javascript - jsTree插件中如何获取父li类

javascript - 客户端存储数据的最佳方式

javascript - 将 React 组件转换为单个 js 文件以将其与空白 html 集成

javascript - 如何使用时刻格式格式化时间段?

javascript - 如何将 bower 包依赖项排除在我的汇总包之外?