3 ms·
The above code will print out an off-by-one index for each element (starts at 1 and not 0). Given that the loop also fails to complete if someArray contains a
by al2o3cr 13y ago
The above code will print out an off-by-one index for each element (starts at 1 and not 0).
Given that the loop also fails to complete if someArray contains a falsy value, I'd say this trick falls into the "too cute to be safe" category.