Skip to content

Instantly share code, notes, and snippets.

@ppurang
Created October 7, 2013 08:57
Show Gist options
  • Save ppurang/6864736 to your computer and use it in GitHub Desktop.
Save ppurang/6864736 to your computer and use it in GitHub Desktop.
getFileExtension from You Can't JavaScript Under Pressure
//caution this is a very bad idea for a function even in javascript!
function getFileExtension(i) {
// i will be a string, but it may not have a file extension.
// return the file extension (with no period) if it has one, otherwise false
var x;
if(i.lastIndexOf(".") > -1)
x = i.substring(i.lastIndexOf(".")+1, i.length);
else
x = false;
return x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment