Get extension of file in Javascript

function getExt(filename){ var ext = filename.split('.').pop(); if(ext == filename) return ''; return ext;}
return /[^.]+$/.exec(filename);