jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Comparison between the different ways of checking if a value is an array.
Changed so that it also checks non-arrays for "array-ness"
var testArray = [1, 'hi', false, 3400.5, [1, 2, 3], {'b': 42}],
testObject = {'a': 15.1, 'beta': true, 3: 'hello', true: undefined},
testString = 'I am a string',
testNumber = 150.1,
testBool = true,
testUndefined = undefined;
function instanceofArray(suspect) {
return (suspect instanceof Array);
}
function constructorArray(suspect) {
return (suspect.constructor === Array);
}
function isArrayArray(suspect) {
return Array.isArray(suspect);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
instanceof testArray |
| ready |
instanceof testObject |
| ready |
instanceof testString |
| ready |
instanceof testNumber |
| ready |
instanceof testBool |
| ready |
instanceof testUndefined |
| ready |
constructor == testArray |
| ready |
constructor == testObject |
| ready |
constructor == testString |
| ready |
constructor == testNumber |
| ready |
constructor == testBool |
| ready |
isArray testArray |
| ready |
isArray testObject |
| ready |
isArray testString |
| ready |
isArray testNumber |
| ready |
isArray testBool |
| ready |
isArray testUndefined |
| ready |
"instanceof" summary |
| ready |
"constructor ==" summary |
| ready |
"isArray" summary |
| ready |
wrapped instanceof |
| ready |
wrapped constructor |
| ready |
wrapped isArray |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.