Get everything after the dash in a string in javascript

前端 未结 9 2065
故里飘歌
故里飘歌 2020-11-30 22:47

What would be the cleanest way of doing this that would work in both IE and firefox.

My string looks like this: sometext-20202

Now the \'sometext\' and the

9条回答
  •  鱼传尺愫
    2020-11-30 23:29

    A solution I prefer would be:

    const str = 'sometext-20202';
    const slug = str.split('-').pop();
    

    Where slug would be your result

提交回复
热议问题