Search code examples
javascriptbackwards-compatibilitypolyfills

Using "let" in javascript in terms of browser compatibility?


What are the options for using the let keyword in javascript. It seems like it would be really useful.

I've seen traceur, but I'm wondering if there are any other options, so I don't have to run entire projects through it.

Is it even possible with some type of polyfill or library. Or do I basically have to wait until all the old browsers die out to use it natively...


Solution

  • There is absolutely no way to mimic / shim a keyword in ECMAscript. So you either choose to totally go with it (which might be a very bad idea at present) or you can't use it yet.

    As you might know, let is part of ECMAscript Next / Harmony and at best, its just available as experimental feature in some browsers. Even if let is a very stable feature, ES.Next spec is still in flux even. Go play with it, but it really makes no sense to rely on it imho.