I am using const
with the new for of
looping structure of JavaScript. It works fine in Chrome but in MS Edge the following code throws error:
for(const a of [1, 2, 3])
console.log(a);
Error: Const must be initialized
Again, works fine in chrome, edge throws error. I guess it expects const variable to have an initialization value but that's the entire job of the for isn't it?
MDN says edge supports the loop so browser support isn't an issue.
According to https://kangax.github.io/compat-table/es6, "const
in for-of
loop iteration scope" is not supported in IE and not in Edge until version 14. It's the same with let
btw. Basic for of
loops, and basic const
/let
usage do work though. MDN is not the most accurate source for browser support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With