hasClass vs is so (v21)

Revision 21 of this benchmark created by Ke 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>

Setup

var foo = $('#foo')
  var el = foo[0]

Test runner

Ready to run.

Testing in
TestOps/sec
hasClass
foo.hasClass('bar');
ready
is
foo.is('.bar');
ready
dom
el.className.indexOf('bar') != -1 
ready

Revisions

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