I have the following bit of code to select and remove a d3.js node.
if (d.children) {
for (var child of d.children) {
if (child == node) {
d.children = _.without(d.children, child);
update(root);
break;
}
}
}
This works fine in Chrome and Edge, but fails in IE-11 with missing ;. It appears to be a problem with using 'of' to loop. Has anyone else run across this issue with IE before and if so how did you resolve it?
I have the following bit of code to select and remove a d3.js node.
if (d.children) {
for (var child of d.children) {
if (child == node) {
d.children = _.without(d.children, child);
update(root);
break;
}
}
}
This works fine in Chrome and Edge, but fails in IE-11 with missing ;. It appears to be a problem with using 'of' to loop. Has anyone else run across this issue with IE before and if so how did you resolve it?
Share Improve this question edited Sep 24, 2016 at 18:02 altocumulus 21.6k13 gold badges64 silver badges86 bronze badges asked Sep 23, 2016 at 22:26 Michael McCurleyMichael McCurley 1931 gold badge2 silver badges8 bronze badges 2 |1 Answer
Reset to default 19This is an ES2015 (also know as ES6) feature and only supported in modern browsers. Generally you would only use this construct together with a transpiler like babel in order to support older browsers.
You can see the compatibility table for the for...of
statement here:
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/for...of
for..in
? – maurycy Commented Sep 24, 2016 at 12:50