Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Проверка 2-х классов
(version: 0)
Comparing performance of:
length vs hasClass vs indexOf simplest vs classList
Created:
5 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <body id="top_page" class="x-competitions x-20 x-players"></body>
Tests:
length
if ($(".x-competitions.x-players").length) { }
hasClass
if ($("body").hasClass("x-competitions") && $("body").hasClass("x-players")) { }
indexOf simplest
if (document.body.className.indexOf("x-competitions") !== -1 && document.body.className.indexOf("x-players") !== -1) { }
classList
if (document.body.classList.contains('x-competitions') && document.body.classList.contains('x-players')) { }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
length
hasClass
indexOf simplest
classList
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Find vs select
Find vs select
spread vs for of
Class vs Id Jquery
Class vs Id Jquery 2
Comments
Confirm delete:
Do you really want to delete benchmark?