문제

How do I parse this to int?

"'10'"

Thanks.

도움이 되었습니까?

해결책

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

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

or

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

다른 팁

Or you could do:

var num = +str.split("'")[1]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top