See code:
var file1 = \"50.xsl\"; var file2 = \"30.doc\"; getFileExtension(file1); //returns xsl getFileExtension(file2); //returns doc function getFileExt
Wallacer's answer is nice, but one more checking is needed.
If file has no extension, it will use filename as extension which is not good.
Try this one:
return ( filename.indexOf('.') > 0 ) ? filename.split('.').pop().toLowerCase() : 'undefined';