Split vs slice/indexOf (v4)

Revision 4 of this benchmark created by Softm on


Preparation HTML

<script>
  var str = "123-341235";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Split
str.split('-')[1]
ready
Slice/indexOf
str.slice(str.indexOf('-') + 1)
ready
Substr/indexOf
str.substr(str.indexOf("-") + 1);
ready
Another index of method
alert(str.substr(str.indexOf("-") + 1));
ready
pop value
str.split("-", 2).pop()
ready

Revisions

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