regex test vs. lastindexof

Benchmark created by Eroan on


Setup

var file = 'file.css';

Test runner

Ready to run.

Testing in
TestOps/sec
regexp
if (/\.css[^\.]*$/.test(file)) {
var i = 1;
}
ready
Lastindexof
if(file.substr(file.lastIndexOf(".") + 1) == 'css'){
var i = 1;
}
ready
slice
if(file.slice(-4)=='.css'){
var i = 1;
}
ready

Revisions

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