Strangest language feature - Stack Overflow
stackoverflow.com
stackoverflow.com
This is a valid for-loop in JavaScript
for (;;) {}
(Saw it for the first time in Crockford's jsLint) while (1) {...}
and I've heard it referred to as a "forever" loop. It's a natural consequence of each term of the for being optional---skip the init and/or the update, and nothing happens, skip the test and it just always evaluates to true. var i = 0;
for (;;) {
log(i);
i++;
if (i > 10) {
break;
}
};
In a way is recursion, it is equivalent to this: var i = 0;
(function () {
log(i);
i++;
if (i > 10) {
return;
}
arguments.callee();
})();