同时导入 ES6 和 ES7 core-js polyfill 有什么用吗?
Is there any use in importing both ES6 and ES7 core-js polyfills?
为 Object
导入 ES6 polyfill 有用还是多余
import 'core-js/es6/object';
以及 Object
?
的 ES7 polyfill
import 'core-js/es7/object';
ES7 polyfill 是否涵盖了所有 ES6 功能,我可以不使用 ES6 polyfill,还是 ES6 polyfill 添加了 ES7 polyfill 中不存在的功能?
来自 core-js for different ECMAScript versions are mostly distinct. For example take a look at the object polyfill for ES6 and ES7 的 polyfill。
所以如果你想拥有 ES6 和 ES7 的 polyfilled 功能,你需要导入两者。
这个答案涉及core-js@2
。从 core-js@3
开始,不再有单独的 ES6 和 ES7 前缀。这是由于 ECMAScript 的开发方式。您可以在 core-js@3, babel and a look into the future post.
中找到更多详细信息
是的,有一个用处。简单比较一下core-js/es6/object.js
to core-js/es7/object.js
.
ES6 对象 polyfill 提供:
• Symbol
• Object.create
• Object.defineProperty
• Object.defineProperties
• Object.getOwnPropertyDescriptor
• Object.getPrototypeOf
• Object.keys
• Object.getOwnPropertyNames
• Object.freeze
• Object.seal
• Object.preventExtensions
• Object.isFrozen
• Object.isSealed
• Object.isExtensible
• Object.assign
• Object.is
• Object.setPrototypeOf
• Object.prototype.toString
另一方面,ES7 对象 polyfill 提供:
• Object.getOwnPropertyDescriptors
• Object.values
• Object.entries
• Object.prototype.__defineGetter__
• Object.prototype.__defineSetter__
• Object.prototype.__lookupGetter__
• Object.prototype.__lookupSetter__
因此,ES6 polyfill 确实添加了 only ES6 中引入的方法,这是 not ES7 polyfill 涵盖的。那一个只添加了ES7中引入的方法
core-js 的结构似乎与其他 类.
的结构相同
为 Object
import 'core-js/es6/object';
以及 Object
?
import 'core-js/es7/object';
ES7 polyfill 是否涵盖了所有 ES6 功能,我可以不使用 ES6 polyfill,还是 ES6 polyfill 添加了 ES7 polyfill 中不存在的功能?
来自 core-js for different ECMAScript versions are mostly distinct. For example take a look at the object polyfill for ES6 and ES7 的 polyfill。
所以如果你想拥有 ES6 和 ES7 的 polyfilled 功能,你需要导入两者。
这个答案涉及core-js@2
。从 core-js@3
开始,不再有单独的 ES6 和 ES7 前缀。这是由于 ECMAScript 的开发方式。您可以在 core-js@3, babel and a look into the future post.
是的,有一个用处。简单比较一下core-js/es6/object.js
to core-js/es7/object.js
.
ES6 对象 polyfill 提供:
• Symbol
• Object.create
• Object.defineProperty
• Object.defineProperties
• Object.getOwnPropertyDescriptor
• Object.getPrototypeOf
• Object.keys
• Object.getOwnPropertyNames
• Object.freeze
• Object.seal
• Object.preventExtensions
• Object.isFrozen
• Object.isSealed
• Object.isExtensible
• Object.assign
• Object.is
• Object.setPrototypeOf
• Object.prototype.toString
另一方面,ES7 对象 polyfill 提供:
• Object.getOwnPropertyDescriptors
• Object.values
• Object.entries
• Object.prototype.__defineGetter__
• Object.prototype.__defineSetter__
• Object.prototype.__lookupGetter__
• Object.prototype.__lookupSetter__
因此,ES6 polyfill 确实添加了 only ES6 中引入的方法,这是 not ES7 polyfill 涵盖的。那一个只添加了ES7中引入的方法
core-js 的结构似乎与其他 类.
的结构相同