4 ms·
Strangest language feature - Stack Overflow
- yannis 17y agoHere is my 2cents on top of all those! This is a valid for-loop in JavaScript for (;;) {} (Saw it for the first time in Crockford's jsLint)
- niyazpk 17y agoWhat can it be used for?
- blahedo 17y agoIt's equivalent to 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.
- yannis 17y agoIt is actually a forever/infinite loop unless you break out of it with code like this: 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(); })();
- mooism2 17y agoIt's valid in C and other related languages, too.
- deleted 17y ago[deleted]
- JoeAltmaier 17y agoHow about in C int i=1; int * p = &i; int x = 100/* p; doesn't even compile (why?)