dimanche 22 mars 2015

Can't use "let" keyword in Safari Javascript?


I don't understand the best way to use "let" keyword...



  • In IE11 and Chrome45 I can use it fine

  • In Safari8.0.4, like in older versions of Chrome, it gives the error "unexpected use of reserved word 'let'"

  • In Firefox the let keyword only works inside <script type="application/javascript;version=1.7"/>, but this script type isn't even recognized as Javascript in IE11, Chrome45, Safari8.


Here's a JSFiddle that shows it in action: http://ift.tt/1HlBOiX


So -- I don't mind requiring users to use modern versions of their browsers.


And I don't mind excluding Safari if there honestly is no version of Safari that supports this keyword. (Is that really true? Why does everyone spend all their time griping about IE when Safari seems so much worse in ES6 terms? Have I missed something?).


But how should I allow "let" to work in Firefox while not preventing Chrome/IE? (I haven't yet found links from people griping about how Firefox script tag behaves differently from Chrome, and I'd have expected more complaints, so I figure I must have missed something obvious...)





Aucun commentaire:

Enregistrer un commentaire