JavaScript syntax: Difference between revisions

Content deleted Content added
Line 158:
<syntaxhighlight lang="javascript">
for (const i = 0; i < 10; i++) console.log(i); // throws a TypeError: Assignment to constant variable
 
for (const i of [1,2,3]) console.log(i); //will not raise an exception. i is not reassigned but recreated in every iteration
 
const pi; // throws a SyntaxError: Missing initializer in const declaration