hasClass vs is with multiple classes (v13)

Revision 13 of this benchmark created by Bob Radu on


Preparation HTML

<div id="foo" class"classOne">I am a DIV</div>
<div id="foo1" class"classTwo">I am a DIV</div>
<div id="foo2">I am a DIV</div>
<div id="foo3">I am a DIV</div>
<div id="foo4">I am a DIV</div>
<div id="foo5">I am a DIV</div>
<div id="foo6" class"classOne">I am a DIV</div>
<div id="foo7">I am a DIV</div>
<div id="foo8" class"classTwo">I am a DIV</div>
<div id="foo9">I am a DIV</div>
<div id="foo10">I am a DIV</div>
<div id="foo11">I am a DIV</div>
<div id="foo12">I am a DIV</div>
<div id="foo13" class"classOne">I am a DIV</div>
<div id="foo14">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('classOne') || $('#foo').hasClass('classTwo');
ready
is
$('#foo').is('.classOne, .classTwo');
ready

Revisions

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