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

前端 未结 23 2038
醉酒成梦
醉酒成梦 2020-11-30 17:21

For example, assuming that x = filename.jpg, I want to get filename, where filename could be any file name (Let\'s assume the file nam

23条回答
  •  借酒劲吻你
    2020-11-30 17:29

    Another one liner - we presume our file is a jpg picture >> ex: var yourStr = 'test.jpg';

        yourStr = yourStr.slice(0, -4); // 'test'
    

提交回复
热议问题