split vs lastIndefOf

Benchmark created on


Setup

const currentLabel = "I::think::Ruth's::dog::is::cuter::than::your::dog!";

const searchTerm = '::';


Test runner

Ready to run.

Testing in
TestOps/sec
split
const splitLabel = currentLabel.split('::');
const lastWord = splitLabel.pop(); // Remove the last element
ready
lastIndexOf
const index = currentLabel.lastIndexOf(searchTerm);
const lastWord = index == -1 ? currentLabel : currentLabel.substring(index + 2)
ready

Revisions

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