Array initialisation in javascript
It bugs me stepping through for() loops, especially where there's more than, say, 7 iterations.
The following uses a C-esque approach.
var n = 1000 var e = [] var c = 0 while (0 === (e[c++] = 0) && c < n){}
So assign zero to the c'th item of array e, then increment e. The assignment returns zero which is === to zero. Keep doing that while c is less than n.
In browser debuggers and Visual Studio there's no stepping through the loop. Instead, it just does its thing and moves on.
© Copyright Bruce M. Axtens, 2013.












