Array length vs falsey

JavaScript performance comparison

Test case created by Josh Schumacher

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var test = [];
    var test2 = [8,2,2,4,6,2,45,2,5,2,589,92,28482,924,292,928];
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Check Length === 0
if (test.length === 0) {
  void(null);
}

if (test2.length === 0) {
  void(null);
}
pending…
Check falsey
if (!test) {
  void(null);
}

if (!test2) {
  void(null);
}
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment