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?
Internet Explorer 11 doesn't support JavaScript versions later than ES5. If you want to use the syntax and features of ECMAScript 2015 or later, or TypeScript, you have two options as described in this article. You can also combine these two techniques.
Browser Compatibility #let and const work in all modern browsers, and IE11 and up.
Internet Explorer When the "Internet Options" window opens, select the Security tab. On the "Security" tab, make sure the Internet zone is selected, and then click on the "Custom level..." button. In the Security Settings – Internet Zone dialog box, click Enable for Active Scripting in the Scripting section.
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
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