2

Looking through the Mozilla JavaScript site, I see that JavaScript 1.8 has a lot of great functions. In most cases it has code you can add to extend prototypes of the basic types in the case that the function is not implemented on the user's browser. Is there a library that you can use to add all those functions and therefore use JavaScript 1.8 freely in your code?

Joe
  • 7,922
  • 18
  • 54
  • 83
  • I don't know that there aren't libraries that have tried but I know there are features that you couldn't override or prototype in like generator expressions because they have entirely new syntax (the `yield` keyword). – nwellcome Feb 15 '12 at 17:32
  • I understand that a library cannot add new syntax and that I can't user the "let" keyword, for example. But many functions can be implemented. So the sirhc's answer was the one I was looking for. – Joe Feb 15 '12 at 21:03

2 Answers2

2

You are probably looking for a shim.
Check out the es5-shim: https://github.com/kriskowal/es5-shim/

Modernizr has a pretty exhaustive list (wiki) of alternative polyfills or shims (look under ECMAScript 5 for your needs): https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills

Also, not all features can be provided by shims or polyfills. You could start an issue (remember to search and read the README first) for a feature that you want but isn't provided and the developer might tell you if it's not possible.

sirhc
  • 6,097
  • 2
  • 26
  • 29
2

Since this version has lots of syntax differences (mentioned by Rob W), there are only two way this can be done

  • Somebody would have to write a JS interpreter in JavaScript, which would be good awful slow.
  • Write a server side compiler that turns JavaScript 1.8 into EcmaScript.

No, there isn't one out there.

Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217