I am using “for...of” in many places in my Javascript code which is a new technology, part of Javascript’s new specification (ECMAScript 2015 (E56) standard). "for...of" is supported in Chrome, Safari and Firefox. Though, IE doesn’t yet support this new feature (See this link). What would be my best approach to support these 4 main browsers - do I revert to "for in/for loop" or do I use browser-sniffing code or is there a better hack to be able to both use some hybrid "for...of" and "for...in"? This is not a repeat of this question here: link_here because I am aware that IE does not support "for...of". What I am looking for is if there is a hack to still use it and still support all the 4 browsers I listed?
for...of - JavaScript keyword Internet Explorer work-around
331 views Asked by Kapil Vyas At
2
There are 2 answers
0
On
If you want back compat support for "for...of" your only choice is a compiler (transpiler). If you look here: https://kangax.github.io/compat-table/es6/ the well known compilers, and the level of support they provide, are well documented.
You can add the Traceur compiler:
It should work even on IE9.