导入ES6和ES7 core-js polyfills有什么用处吗?

Ion*_*aru 11 javascript polyfills

导入ES6 polyfill是有用还是多余的 Object

import 'core-js/es6/object';
Run Code Online (Sandbox Code Playgroud)

以及ES7的polyfill Object

import 'core-js/es7/object';
Run Code Online (Sandbox Code Playgroud)

ES7 polyfill是否涵盖了ES6的所有功能,是否可以将ES6 polyfill放在外面,或者ES6 polyfill是否添加了ES7 polyfill中不存在的功能?

Jus*_*ent 15

是的,有用.简单地比较core-js@2core-js@3.

该ES6对象填充工具提供:
•  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  core-js/es6/object.js
core-js/es7/object.js
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

在另一方面,ES7对象填充工具提供:
•  •  •  •  •  •  •  Object.setPrototypeOf
Object.prototype.toString
Object.getOwnPropertyDescriptors
Object.values
Object.entries
Object.prototype.__defineGetter__
Object.prototype.__defineSetter__

因此,ES6 polyfill确实添加了ES6中引入的方法,而ES7 polyfill 并未涵盖这些方法.这一个增加了在ES7方法介绍.

core-js似乎与其他类的结构相同.