admin管理员组文章数量:1201792
Is it useful or redundant to import the ES6 polyfill for Object
import 'core-js/es6/object';
and also the ES7 polyfill for Object
?
import 'core-js/es7/object';
Does the ES7 polyfill cover all of the ES6 features and can I leave the ES6 polyfill out, or does the ES6 polyfill add features not present in the ES7 polyfill?
Is it useful or redundant to import the ES6 polyfill for Object
import 'core-js/es6/object';
and also the ES7 polyfill for Object
?
import 'core-js/es7/object';
Does the ES7 polyfill cover all of the ES6 features and can I leave the ES6 polyfill out, or does the ES6 polyfill add features not present in the ES7 polyfill?
Share Improve this question edited Aug 8, 2017 at 12:28 Just a student 11k2 gold badges44 silver badges71 bronze badges asked Aug 8, 2017 at 11:44 IonaruIonaru 1,0503 gold badges14 silver badges23 bronze badges2 Answers
Reset to default 18This answer concerns core-js@2
. Starting from core-js@3
, there are no longer separate ES6 and ES7 prefixes. This is due to how ECMAScript developed. You can find more details in the core-js@3, babel and a look into the future post.
Yes, there is a use. Simply compare core-js/es6/object.js
to core-js/es7/object.js
.
The ES6 object polyfill provides:
• 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
On the other hand, the ES7 object polyfill provides:
• Object.getOwnPropertyDescriptors
• Object.values
• Object.entries
• Object.prototype.__defineGetter__
• Object.prototype.__defineSetter__
• Object.prototype.__lookupGetter__
• Object.prototype.__lookupSetter__
Thus, the ES6 polyfill indeed adds only methods introduced in ES6 and this is not covered by the ES7 polyfill. That one only adds methods introduced in ES7.
core-js appears to be structured the same way for other classes.
The polyfills from core-js for different ECMAScript versions are mostly distinct. For example take a look at the object polyfill for ES6 and ES7.
So you need to import both if you want to have the features from ES6 and ES7 polyfilled.
本文标签: javascriptIs there any use in importing both ES6 and ES7 corejs polyfillsStack Overflow
版权声明:本文标题:javascript - Is there any use in importing both ES6 and ES7 core-js polyfills? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738639740a2104238.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论