JSFiddle - React, Tailwind, and code Playground

JavaScript

function ext2(f) {
    var a = f.lastIndexOf('.'); 
    if (a > 0) 
        return f.substr(a + 1);
    else 
        return '';
}
function ext1(filename)
{
    return filename.substr((~-filename.lastIndexOf(".") >>> 0) + 2);
}
function test(action, iterations) {
    function runTest(action) {
        var t0 = performance.now();
        action();
        var t1 = performance.now();
        return t1 - t0;
    }
    var res = 0;
    for(var i = 0; i < iterations; i++ ){
        res += runTest(action);
    };
    return res / iterations;
}
var iterations = 1000000;
var str = 'dfdf.ext';
var str2 = 'dfdf';

var f1 = ext1.bind(null, str);
var f2 = ext2.bind(null, str);
console.log('ext1: ' + test(f1, iterations) + ' ms');
console.log('ext2: ' + test(f2, iterations) + ' ms');

console.log('=====');

f1 = ext1.bind(null, str2);
f2 = ext2.bind(null, str2);
console.log('ext1: ' + test(f1, iterations) + ' ms');
console.log('ext2: ' + test(f2, iterations) + ' ms');