/ JAVASCRIPT, FRONT-END

How to get value after a symbol in a string in Javascript?

Question

I have a string call abcfdhsfjkds-21947, and I want to get the value after the symbol -, how to do that?

Answer

var str = 'abcfdhsfjkds-21947';
var result = str.split('-').pop();

The result is the value you want.

Reference


This is the end of post