Get value of a string after last slash in JavaScript

前端 未结 10 1442
感情败类
感情败类 2020-11-29 19:05

I am already trying for over an hour and cant figure out the right way to do it, although it is probably pretty easy:

I have something like this : foo/bar/test

10条回答
  •  猫巷女王i
    2020-11-29 19:28

    Try this:

    const url = "files/images/gallery/image.jpg";
    
    console.log(url.split("/").pop());

提交回复
热议问题