by @kodeazy
How to get substring before specific character in javascript?
- In this blog we will discuss on how to get substring before specific character in javascript.
- To get the
sub string
before specific character in a string we split the string until that character. -
Below is the sample example of getting the
sub string
uptill,
in javascript.var str="sam, 4th avenue"; console.log(str.split(",")[0]);
Output:
sam