是否已经有一个开源项目可以为本身不实现 ECMAScript 5 功能的浏览器实现它?类似于 IE7.js 项目,它实现了 Internet Explorer 中缺少的标准内容。
我想使用新的 Function.bind() 、 String.trim() 和 JSON.parse() 函数,但它们目前仅在最新的浏览器(例如最新的 Chromium)中可用。我想简单地包含一个像“ecma5.js”这样的脚本,然后如果浏览器中缺少这些脚本,它就会实现所有这些内容。
那么已经有这样的项目可用了吗?如果没有的话我就得自己做。
Is there already a opensource project out there which implements ECMAScript 5 features for browsers which do no implement it natively? Something like the IE7.js project which implements missing standard stuff in Internet Explorer.
I'd like to use the new Function.bind() and String.trim() and JSON.parse() functions but they are currently only available in the newest browsers like the latest Chromium. I'd like to simply include a script like "ecma5.js" which then implements all this stuff if missing in the browser.
So is there already a project like this available? If not then I have to do it myself.
发布评论
评论(3)
es5-shim 应该给你你想要的(或者,尽可能接近它......请务必阅读注意事项)。您可以在此处找到其他 polyfill 的列表。
es5-shim should give you what you want (or, as close to it as possible... be sure to read the caveats). You can find a list of other polyfills here.
DDR-ECMA5 库旨在执行您所要求的操作。当然,并不是所有的事情都可以用 ECMAScript 3 标准来实现,但尽可能多的是。
DDR-ECMA5 library is intended to do what you asked. Of course not everything is possible to be implemented with ECMAScript 3 standard, but as much as possible is there.
如果您不介意学习该库并自己编写一些代码,您可以在
https://developer.mozilla.org/En/JavaScript/ECMAScript_5_support_in_Mozilla
例如,Array.filter
然后 Crockford 在 json2.js 中有 JSON.parse/stringify
If you don't mind learning the library and writing some code yourself, you can find some code implementations of the ECMAScript 5 library at
https://developer.mozilla.org/En/JavaScript/ECMAScript_5_support_in_Mozilla
For example, the code for Array.filter
And then Crockford has JSON.parse/stringify in json2.js
https://github.com/douglascrockford/JSON-js