No, according to the specification , the length array is a non-negative integer:
Each Array object has a length property, the value of which is always a non-negative integer less than 2 ^ 32 .
Either the check is fine, and both will have the same results for all arrays.
You can find people who argue about === 0 over < 1 because of performance because === cannot be executed earlier if the types of its operands do not match, but < tries to apply type coercion. But it does not matter here; types match. I do not know any evidence that either faster than the other in this use case (and I tested it, unfortunately, jsPerf is disabled, so I can not publish the test), but even if that were the case, they should do the comparison literally in billions of times to see even the smallest influence of the real world.
Tj crowder
source share