jslint
jslint copied to clipboard
error on for...of statement
Firstly thanks for writing jslint, secondly I found this new for-of loop that javascript has https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of but js lint throws the error
Expected ';' and instead saw 'of'.
(function(){ 'use strict'; let arr = [3, 5, 7]; let i; arr.foo = "hello"; for (i of arr) { console.log(i); // logs "3", "5", "7", "hello" } }());
I could always use forEach instead but then I can't break out of the loop
(function () { 'use strict'; let arr = [3, 5, 7]; arr.foo = "hello"; arr.forEach(function (element, index) { console.log(element); // logs "3", "5", "7" console.log(index); // logs "0", "1", "2" }); }());
what is your opinion, is the for of loop useful or should I use something else instead. Thanks