DEV Community

Avinashd
Avinashd

Posted on

Js in bits - 7(Type Conversions)

Learning js should be fun. It is fun if it's easy.
I tried my best in writing this, to understand it the easy way.

Type Conversions

Most of the time, operators & functions automatically convert the vals given to them to the right type.

Image description

String Conversion
Image description

Number Conversion
Conversion happens in Mathematical functions & expressions automatically.

Image description

A valid string(number) will be converted to valid number

Image description

Invalid string(number) results in NaN

Image description

Math conversion rules:
Image description

Boolean Conversion
Few valid boolean conversions that results in false

Image description

Examples of boolean conversion:

Image description

Leave y'r thoughts....

Top comments (0)