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%.
这有什么意义?
最佳答案
在 ES2015 之前,只有单一类型的函数。 ES2015介绍了箭头函数、生成器函数和方法。生成器函数和类方法不一定以Function.prototype
作为其原型(prototype)。例如:
9.2.6 GeneratorFunctionCreate (kind, ParameterList, Body, Scope, Strict)
- Let functionPrototype be the intrinsic object
%Generator%
.- Let F be FunctionAllocate(functionPrototype, Strict,
"generator"
).- Return FunctionInitialize(F, kind, ParameterList, Body, Scope).
这些函数的绑定(bind)版本可能应该“保留”原始函数的原型(prototype)。
关于javascript - ES2015 规范附录 E 中的此条目有何意义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44420105/