typeof

JavaScript performance comparison

Test case created by Mike Wilcox

Info

Is typeof faster than truthy tests?

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/dojo/1/dojo/dojo.xd.js"></script>
 

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
typeof
var o;
var r1 = typeof o !== "undefined";
var d = dojo;
var r2 = typeof d !== "undefined";
 
pending…
truthy
var o;
var r1 = !!o
var d = dojo;
var r2 = !!d;
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