Skip to content

Instantly share code, notes, and snippets.

@hoyangtsai
Last active April 11, 2020 10:11
Show Gist options
  • Save hoyangtsai/9f0a22a00d146e645f2dd36cc0f6723a to your computer and use it in GitHub Desktop.
Save hoyangtsai/9f0a22a00d146e645f2dd36cc0f6723a to your computer and use it in GitHub Desktop.
get file name without extension
// https://stackoverflow.com/questions/4250364/how-to-trim-a-file-extension-from-a-string-in-javascript/34301737
// splite string into array by dot
// slice from the beginning to the second last to rid of the extension
// join the array and remain the dot within the name
filename.split('.').slice(0, -1).join('.')
// get file extension
filename.split('.').slice(-1).join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment