Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 have to do it myself.

like image 706
kayahr Avatar asked Mar 15 '11 15:03

kayahr


People also ask

What version of ECMAScript do browsers support?

Browser SupportECMAScript 1 - 6 is fully supported in all modern browsers.

How do I make JavaScript code compatible with every browser?

Use browser developer tools/dev tools that help to debug JavaScript. In most browsers, the JavaScript console will flag and report errors in code. Use the Console API to allow JS source code to communicate with the browser's JS console. Console API's most widely used feature is console.


2 Answers

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.

like image 148
Nathan Ostgard Avatar answered Oct 04 '22 19:10

Nathan Ostgard


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.

like image 39
Dawid Avatar answered Oct 04 '22 20:10

Dawid