if exists (v16)

Revision 16 of this benchmark created on


Setup

var myArray = [];
  myArray["ala"] = "ola";
  myArray["alama"] = "olama";
  myArray["alamakota"] = "olamakota";

Test runner

Ready to run.

Testing in
TestOps/sec
first elem var
var elem = myArray["ala"];
result = "";
if (elem) {
  result = elem;
}
ready
first elem no var
result = "";
if (myArray["ala"]) {
  var elem = myArray["ala"];
  result = elem;
}
ready
last elem var
var elem = myArray["alamakota"];
result = "";
if (elem) {
  result = elem;
}
ready
last elem no var
result = "";
if (myArray["alamakota"]) {
  var elem = myArray["alamakota"];
  result = elem;
}
ready

Revisions

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