Easy Way To Convert A String To A Number Or Null?
Is there a slick way to convert a string to a number or null if it cannot be represented by a number? I have been using the method below: if _.isNaN( Number(mystring) ) then null
Solution 1:
If you don't care for "0", then you can use
+s||null
If you want to support "0"
, then I don't have better than
1/s?+s:null
Post a Comment for "Easy Way To Convert A String To A Number Or Null?"