hasClass--stillahead

JavaScript performance comparison

Test case created by pavelrevers

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js"></script>
<div class="class first second third"></div>
<div class="class first third"></div>
<script>
Benchmark.prototype.setup = function() {
    var class = /\bsecond\b/;
    var divs = document.getElements('.class');
};
</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
hasClass
divs[0].hasClass('second');
divs[1].hasClass('second');
pending…
regexp
divs[0].className.test(class);
divs[1].className.test(class);
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