Header Ads Widget

Responsive Advertisement

type conversion and type coercion

Type conversion: it converts one data type to another data type. Only 3 data type can be converted: number, string, boolean.

E.g: 
let name = '1234'
console.log(typeof(name));
Output: string
console.log(Number(name));
Output: number


Coercion: javascript automatically ex cutes whenever the operator deals with different format. So JavaScript converts on one of the value based upon the operator.
Not all the operator support this type corrosion. The only task failed by the type coercion.




Post a Comment

0 Comments