You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chromium浏览器中array.push的实现问题及跨浏览器差异问询

Array.push的Babel Polyfill问题与浏览器实现差异

我一直以为Array.push是JavaScript里最基础的方法之一,没想到Babel会针对Chromium系浏览器(Chrome、Edge)为这个方法添加polyfill。翻了MDN的Array.push文档和core-js的实现代码,还是没搞明白这个polyfill是要修复Chromium里的什么问题,同时也想了解Firefox、Safari和Chromium在这个方法上的实现差异。

core-js3的polyfill列表参考

core-js3 添加的polyfill如下:
  es.object.to-string { "ie":"10" }
  es.promise { "ie":"10" }
  web.dom-collections.for-each { "ie":"10" }
  es.array.from { "ie":"10" }
  es.string.iterator { "ie":"10" }
  es.array.push { "chrome":"115", "edge":"110", "ie":"10" } //仅针对Chromium,不包含Firefox和Safari
  ...

禁用Array.push polyfill的Babel配置

如果要让Babel不为Array.push添加polyfill,需要在Babel配置里加入exclude项:

{
  "useBuiltIns": "usage",
  "shippedProposals": true,
  "corejs": "3.33",
  "exclude": ["es.array.push"]
}

内容的提问来源于stack exchange,提问作者Qiulang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 13:15:02