It's known that in general, JavaScript allows an inline for loop in the format:
someArray.forEach(x => x.doSomething());
However, when one wants to use a regular for-loop inline, as one statement, an error is occured. For example:
void(for(var i = 0; i < 0; i++) console.log(i));
Even though this is technically one line, but since it's used in a format of literally being inline, and being considered one statement, it gives the error:
Uncaught SyntaxError: Unexpected token 'for'
Why might one want to do this? Simple: in order to generate an array, or string, in one line, for example:
var newString = (let k = "", for(let i = 0; i < 1000; i++) k+= i, k);
But this gives an obvious
Uncaught SyntaxError: Unexpected identifier
error, because of the "let" keyword, but that's a different question.
Mainly, is it possible to make a regular for-loop inline in JavaScript?