JavaScript | Type Conversion JavaScript is loosely typed language and most of the time operators automatically convert a value to the right type but there are also cases when we need to explicitly do type conversions. While JavaScript provides numerous ways to convert data from one type to another but there are two most common data conversions : Implicit Conversion explicit conversion Implicit Conversion When JavaScript tries to operate on a "wrong" data type, it will try to convert the value to a "right" type . This is known as implicit conversion.it is call Automatic type conversion Example 1: Implicit Conversion to String // numeric string used with + gives string type let sum ; sum = '3' + 2 ; console . log ( sum ) // "32" sum = '3' + true ; console . log ( sum ); // "3true" sum = '3' + undefined ; console . log ( sum ); // "3undefined" sum = '3'
Amritanjali's blog UI Source on UI related technologies like Angular, TypeScript, JavaScript, HTML, CSS.