_.isString vs typeof string

JavaScript performance comparison

Test case created

Preparation code

<script src="https://raw.github.com/documentcloud/underscore/master/underscore-min.js"></script>
 
<script>
Benchmark.prototype.setup = function() {
    var teststring = "Hallo! Ich bin ein String!",
        testobj = { not: "a string" };
};
</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 String
typeof(teststring) === "string";
typeof(testobj) !== "string";
pending…
Underscore isString
_.isString(teststring);
!_.isString(testobj);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment