replace() or substr() (v23)

Revision 23 of this benchmark created on


Setup

var str = "a.aa.a.aa.";
    var regEx = /\.$/;

Test runner

Ready to run.

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

Revisions

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