isTruthy vs isDefined

JavaScript performance comparison

Test case created by zerious

Preparation code

<script>
var o = { n: 1 };
</script>
    

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
isTruthy(number)
var a = o.n ? 1 : 2, b = o.n ? 1 : 2,
    c = o.n ? 1 : 2, d = o.n ? 1 : 2,
    e = o.n ? 1 : 2, f = o.n ? 1 : 2,
    g = o.n ? 1 : 2, h = o.n ? 1 : 2,
    i = o.n ? 1 : 2, j = o.n ? 1 : 2;
pending…
isTruthy(undefined)
var a = o.u ? 1 : 2, b = o.u ? 1 : 2,
    c = o.u ? 1 : 2, d = o.u ? 1 : 2,
    e = o.u ? 1 : 2, f = o.u ? 1 : 2,
    g = o.u ? 1 : 2, h = o.u ? 1 : 2,
    i = o.u ? 1 : 2, j = o.u ? 1 : 2;
pending…
isDefined(number)
var a = o.n !== undefined ? 1 : 2, b = o.n !== undefined ? 1 : 2,
    c = o.n !== undefined ? 1 : 2, d = o.n !== undefined ? 1 : 2,
    e = o.n !== undefined ? 1 : 2, f = o.n !== undefined ? 1 : 2,
    g = o.n !== undefined ? 1 : 2, h = o.n !== undefined ? 1 : 2,
    i = o.n !== undefined ? 1 : 2, j = o.n !== undefined ? 1 : 2;
pending…
isDefined(undefined)
var a = o.u !== undefined ? 1 : 2, b = o.u !== undefined ? 1 : 2,
    c = o.u !== undefined ? 1 : 2, d = o.u !== undefined ? 1 : 2,
    e = o.u !== undefined ? 1 : 2, f = o.u !== undefined ? 1 : 2,
    g = o.u !== undefined ? 1 : 2, h = o.u !== undefined ? 1 : 2,
    i = o.u !== undefined ? 1 : 2, j = o.u !== undefined ? 1 : 2;
pending…
isUndefined(number)
var a = o.n === undefined ? 2 : 1, b = o.n === undefined ? 2 : 1,
    c = o.n === undefined ? 2 : 1, d = o.n === undefined ? 2 : 1,
    e = o.n === undefined ? 2 : 1, f = o.n === undefined ? 2 : 1,
    g = o.n === undefined ? 2 : 1, h = o.n === undefined ? 2 : 1,
    i = o.n === undefined ? 2 : 1, j = o.n === undefined ? 2 : 1;
pending…
isUndefined(undefined)
var a = o.u === undefined ? 2 : 1, b = o.u === undefined ? 2 : 1,
    c = o.u === undefined ? 2 : 1, d = o.u === undefined ? 2 : 1,
    e = o.u === undefined ? 2 : 1, f = o.u === undefined ? 2 : 1,
    g = o.u === undefined ? 2 : 1, h = o.u === undefined ? 2 : 1,
    i = o.u === undefined ? 2 : 1, j = o.u === undefined ? 2 : 1;
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