I'm trying to iterate a Javascript Set in Stackblitz: https://stackblitz.com/edit/javascript-set-iterate?file=index.js
for (const n of s) {
array.push(n);
console.log(n);
}
However the for loop has never been entered somehow.
When I opened the Source tab in Chrome Dev Tools and I saw it's translated as:
for (var _i = 0, s_1 = s; _i < s_1.length; _i++) {
var n = s_1[_i];
array.push(n);
console.log(n);
}
Apparently there is no length property for Set in Javascript. It should be size: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set So the loop is skipped by mistake.
If I run the same for...of
code in the browser console it works fine.
Question:
I'm not sure whether it's my Stackblitz configuration wrong (compiler selection of ES5/ES6 etc.?) or it's a Stackblitz bug?
Thanks!