Summary
-
String conversion occurs can be performed with
String(value)
. The conversion to string is obvious for primitive values. -
Numeric conversion can be performed with
Number(value)
and follows the rules:-
undefined
becomesNaN
-
null
becomes0
-
true / false
becomes1 / 0
-
string
is read as is by stripping white spaces from both sides and an empty string gives0
and an error givesNaN
-
-
Boolean conversion can be performed with
Boolean(value)
and follows the rules:-
0, null, undefined, NaN, ""
becomesfalse
-
any other value becomes
true
-