Explain Implicit Type Coercion in JavaScript.

bookmark

Automatic value conversion from one data type to another data type is known as Implicit type coercion in JavaScript. There are many types Number to String, String to Number, Boolean to Number etc. When different values are applied to the datatypes that are not of that value it automatically converts them.

String Coercion:
The time when the number is added to a string, it converts the number type as a string type with the help of the “+” operator.

Example:

var a = 4;

var b = “5”; //number that’s inside double quotes indicate it’s been considered as a string

a + b // Returns “45”