if exists (v15)

Revision 15 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 no var
result = "";
if (myArray["alamakota"]) {
  var elem = myArray["makota"];
  result = elem;
}
ready
last elem var
var elem = myArray["alamakota"];
result = "";
if (elem) {
  result = elem;
}
ready

Revisions

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