1 | parseInt(string, radix); |
parseInt
takes 2 arguments
Number
:
- returns
NaN
for string123sdfdsf
- returns
NaN
forundefined
,NaN
and{}
- returns
0
forfalse
,null
,""
," "
- returns
1
fortrue
parseInt
:
- returns
123
for string123sdfdsf
- returns
NaN
for allfalse
,null
,""
," "
,true
,{}
,undefined
andNaN
parseInt
preferable for inputs where user can leave some additional characters