hasClass vs is so (v19)

Revision 19 of this benchmark created by rulin on


Preparation HTML

<div id="foo">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
is
var ele = $('#foo');
ele.is('.class1, .class2, .class3, .class4');
ready
hasClass
var ele = $('#foo');
ele.hasClass('class1') || ele.hasClass('class2') || ele.hasClass('class3') || ele.hasClass('class4');
ready

Revisions

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