[] vs Array for object conversion
JavaScript performance comparison
Info
In this test we look at some techniques for using Array.
Preparation code
<script>
// Initialize
var result, array = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' '),
Array_prototype_slice = Array.prototype.slice;
// "result" is used to prevent memory leaks found on tests.
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
[].slice() |
|
pending… |
[].slice.call |
|
pending… |
[].slice.apply |
|
pending… |
Array.prototype.slice.call |
|
pending… |
Array.prototype.slice.apply |
|
pending… |
(Saved Array.prototype.slice)() |
|
pending… |
(Saved Array.prototype.slice).call |
|
pending… |
(Saved Array.prototype.slice).apply |
|
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 FGRibreau
- Revision 2: published by Robert K
- Revision 7: published by Leonardo Dutra
0 comments