Trailing slash removal

Benchmark created on


Setup

const value = "https://example.com/some/long/path/";

Test runner

Ready to run.

Testing in
TestOps/sec
Substring
value.substring(0, value.length - 1);
ready
Slice
value.slice(0, -1);
ready
Replace (single slash)
value.replace(/\/$/, "");
ready
Replace (all slashes)
value.replace(/\/+$/, "");
ready

Revisions

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