.hasClass(): RegExp() vs .indexOf()
JavaScript performance comparison
Test case created by ThinkingStiff
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Testing in unknown unknown
| Test |
Ops/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|$)' ) );
|
pending… |
.indexOf() |
'oneclass'.split( ' ' ).indexOf( 'oneclass' ) > -1 'two classes'.split( ' ' ).indexOf( 'classes' ) > -1 'and three classes'.split( ' ' ).indexOf( 'classes' ) > -1
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
Compare results of other browsers
0 comments