regex vs slice (v18)

Revision 18 of this benchmark created on


Setup

var str = "ns1:name";

Test runner

Ready to run.

Testing in
TestOps/sec
regex 1
str.replace(/.*:/g, '');
ready
regex 2
str.replace(/\w+:/, '');
ready
slice
var pos = str.indexOf(":");
str.slice(pos + 1);
ready
.pop
str.split(":").pop()
ready

Revisions

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