extract filename from path

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
lastIndexOf
var fileName = "D:\\my folder\\abc.txt";
return fileName.substr(fileName.lastIndexOf("\\"));
ready
split
var fileName = "D:\\my folder\\abc.txt",
    segs = fileName.split("\\");        
if (segs.length > 1) {
return segs.pop();
}
 
ready

Revisions

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