replace + substring

Benchmark created on


Setup

const regex = /^www./;

Test runner

Ready to run.

Testing in
TestOps/sec
replace
const d = 'www.cnn.com';
const withoutWWW = d.replace(regex, '');
ready
substring
const d = 'www.cnn.com';
const withoutWWW = d.startsWith('www.') ? d.substring(4) : d;
ready

Revisions

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