Type Conversion and Type Coercion in JavaScript

Type Conversion:

•Conversion using  built-in Functions by Developers

Example : String() , Number() and Boolean().




Type Coercion:

•The process of automatic or implicit conversion of values from one data type to another.

•Since JavaScript is a weakly-typed language, in some scenarios Conversions are done by compiler automatically.

     Example : 1== null

Rules :

•String on any side of operand returns converts into string before operation.

•No String on either side with all primitives, it converts into Number before operation.

•Array, Objects are considered as string before conversion.

Please check below video for more detailed explaination on type conversion and type coercion in JavaScript with the help of examples:

Please let me know in case you have any doubts in comments section of video.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s