Last active
April 11, 2020 10:11
-
-
Save hoyangtsai/9f0a22a00d146e645f2dd36cc0f6723a to your computer and use it in GitHub Desktop.
get file name without extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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