سؤال

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