.hasClass(): RegExp() vs .indexOf()

Benchmark created by ThinkingStiff on


Test runner

Ready to run.

Testing in
TestOps/sec
RegExp()
'oneclass'.match( new RegExp( '(\\s|^)' + 'oneclass' + '(\\s|$)' ) );
'two classes'.match( new RegExp( '(\\s|^)' + 'classes' + '(\\s|$)' ) );
'and three classes'.match( new RegExp( '(\\s|^)' + 'classes' + '(\\s|$)' ) );
ready
.indexOf()
'oneclass'.split( ' ' ).indexOf( 'oneclass' ) > -1
'two classes'.split( ' ' ).indexOf( 'classes' ) > -1
'and three classes'.split( ' ' ).indexOf( 'classes' ) > -1
 
ready

Revisions

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

  • Revision 1: published by ThinkingStiff on