instanceOf Array vs Array.isArray()
JavaScript performance comparison
Info
Comparison between the different ways of checking if a value is an array.
Preparation code
<script>
Benchmark.prototype.setup = function() {
var A = [1, 2, 3, 4, 5],
B = ['a', 'b', 'c', 'd', 'e'],
C = [
[1, 2],
[3, 4],
[5, 6],
[7, 8],
[9, 10]
];
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
Instance of Array A |
|
pending… |
Instance of Array B |
|
pending… |
Instance of Array C |
|
pending… |
IsArray A |
|
pending… |
IsArray B |
|
pending… |
IsArray C |
|
pending… |
Constructor of A |
|
pending… |
Constructor of B |
|
pending… |
Constructor of C |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit
to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by Brian Jemilo II
- Revision 2: published by Artur Raczyński
- Revision 3: published
- Revision 4: published
- Revision 5: published by Ezra Olubi
- Revision 6: published by Nikos M.
- Revision 7: published by Itsik Avidan
- Revision 8: published by me
- Revision 9: published
- Revision 10: published
- Revision 11: published
- Revision 15: published
- Revision 16: published
- Revision 17: published
- Revision 18: published
- Revision 19: published by ZAlexz
- Revision 20: published by dalisoft
- Revision 21: published by dalisoft
- Revision 22: published by Mario DE WEERD
0 comments
Comment form temporarily disabled.