replace() or substr() or slice() (v24)

Revision 24 of this benchmark created on


Setup

const input = "a.aa.a.aa.";
const regEx = /\.$/;

Test runner

Ready to run.

Testing in
TestOps/sec
substr
input.substr(0, input.length-1);
ready
replace
input.replace(/\.$/, '');
ready
precompiled replace
input.replace(regEx, '');
ready
slice (using str.length)
input.slice(0, input.length - 1)
ready
slice (with negative arg)
input.slice(0, -1)
ready

Revisions

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