How to trim a file extension from a String in JavaScript?

Not sure what would perform faster but this would be more reliable when it comes to extension like .jpeg or .html

x.replace(/\.[^/.]+$/, "")

Leave a Comment