3 ms·
for ( var i=0; i<n; ++i ) {.. In Javascript this will loop from 0 to n-1 inclusive regardless of using ++i or i++, because that loop 'stepping statement' happe
by strainer 8y ago
for ( var i=0; i<n; ++i ) {..
In Javascript this will loop from 0 to n-1 inclusive regardless of using ++i or i++, because that loop 'stepping statement' happens after the loop body.
Its possible to combine the step in the test to go from 1 to n-1
for ( var i=0; ++i<n; ) {..
best to be aware of the quirk and just do
for ( var i=1; i<n; i++ ) {..