Javascript-type conversion and javascript Conversion
JavaScript is a non-type language, but JavaScript also provides a flexible way to handle Automatic type conversion. The basic rule is that if a value of a type is used in an environment that requires a value of another type, JavaScript automatically converts the value to the required type.
A specific type of JavaScript is listed below for the conversion performed in a specific environment.
Type conversion
Value string numeric Boolean Value Object
"Undefined" NaN false Error Not Defined
Null "null" 0 false Error
Non-null String As is String numeric value or NaN true String object
Empty String As is 0 false String object
0 "0" As is false Number object
NaN "NaN" As is false Number object
Infinity "Infinity" As is true Number object
Negative Infinity "-Infinity" As is true Number object
The string value of all other numeric numbers is an Asis true Number object.
True "true" 1 As is Boolean object
False "false" 0 As is Boolean object
Object toString () valueOf (), toString (), or NaN true As is