hasClass vs is so (v12)

Revision 12 of this benchmark created on


Preparation HTML

<div id="foo" class="bar">I am a DIV</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
hasClass
$('#foo').hasClass('abc') || $('#foo').hasClass('def') || $('#foo').hasClass('ghi') || $('#foo').hasClass('jkl') || $('#foo').hasClass('mno') || $('#foo').hasClass('pqr') || $('#foo').hasClass('stu') || $('#foo').hasClass('vwx') || $('#foo').hasClass('yz');
ready
is
$('#foo').is('.bar,.abc,.def,.ghi,.jkl,.mno,.pqr,.stu,.vwx,.yz');
ready

Revisions

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