Question

How do I parse this to int?

"'10'"

Thanks.

Was it helpful?

Solution

If you really don't want to use replace, you can do

 var num = +str.match(/\d+/)

or

 var num = +str.slice(1,-1)

OTHER TIPS

Or you could do:

var num = +str.split("'")[1]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top