-
"The process of converting one data type into another is known as
type coercion
."Type Coercion can be categorized into two distinct parts:
Implicit
type coercionExplicit
type coercion
-
Implicit type coercion is a feature of JavaScript that
automatically
converts one data type into another during an operation or comparison.let num = 5; let str = "10"; let result = num + str; console.log(result); // Output: "510"
-
Implicit type coercion occurs when the programmer
intentionally
converts a value from one data type to another usingexplicit instructions
orfunctions
provided by the programming language.let num = 5; let str = "10"; let result = num + Number(str); console.log(result); // Output: 15
-
String()
,Number()
,Boolean()
,parseInt()
,parseFloat()
,toString()
,toFixed()
,- and so on...
-
"In JavaScript, type comparison refers to the process of comparing the equality or inequality of values while considering their data types using comparison operators."
-
Comparison operators:
> greater than == equal to < less than != not equal to >= greater than or equal === strict equal to <= less than or equal !== strict not equal to
-