| Viewed 119 times

How to convert string to int in javascript


I have a string of number mixed with a string like "123abc" and I need to convert it to integer "123"

1 Answer
Mohammad Qandeel
Answered
26

it's very easy to parse a string to an integer using parseInt Function

be careful when using parseInt its return just the first number in the string.

example

parseInt("123abc") // 123
parseInt("a123abc")// NaN
 


Related Questions