Skip to content

Instantly share code, notes, and snippets.

@WillSquire
Created June 30, 2015 15:32
Show Gist options
  • Save WillSquire/0ea14469708cc6618dc3 to your computer and use it in GitHub Desktop.
Save WillSquire/0ea14469708cc6618dc3 to your computer and use it in GitHub Desktop.
File extension - Retrieves the file extension from a string.
/**
* Retrieves the file extension from a string.
*
* @param {string} filename
* @returns {string}
*/
function fileExtension(filename) {
return filename.substr(filename.lastIndexOf('.') + 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment