Sunday, May 19, 2024
10
rated 0 times [  13] [ 3]  / answers: 1 / hits: 16144  / 8 Years ago, fri, september 23, 2016, 12:00:00

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?


More From » ecmascript-6

 Answers
12

This 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


[#60616] Thursday, September 22, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eanskylerg

Total Points: 524
Total Questions: 107
Total Answers: 100

Location: Colombia
Member since Mon, May 2, 2022
2 Years ago
;