ECMAScript 5 compatibility script for older browsers
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 ha开发者_JAVA技巧ve to do it myself.
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 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.
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
精彩评论