Test name | Executions per second |
---|---|
isFinite | 535845.6 Ops/sec |
typeof === "number" | 1129057.2 Ops/sec |
varsToCheck = [3, 3.14, "some string", null, undefined];
count = 0;
varsToCheck.forEach(function(v){ if(Number.isFinite(v)) { count++ } });
varsToCheck.forEach(function(v){ if(typeof v === "number") { count++ } });