slice vs substr

Benchmark created on


Preparation HTML

<p id="result"/>
<script>
  function sliceIt(x){
      return x.slice(1,7);
  }
  
  function subIt(x){
      return x.substr(1,7);
  }
</script>

Setup

var p = document.getElementById('result')

Teardown


    p.innerHTML = "";
  

Test runner

Ready to run.

Testing in
TestOps/sec
slice
p.innerHTML = sliceIt("#F16451");
ready
substr
p.innerHTML = subIt("#F16451");
ready

Revisions

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