Articles → JavaScript → Type Coercion In JavaScript
Type Coercion In JavaScript
Scenario
- Use the === operator.
- Type coercion.
Type Coercion
- The integer value of false is 0.
- The integer value of true is 1.
Example
var boolean = true;
var integer = 1;
var booleanInt = Number(boolean); // Type Coercion
if (integer == booleanInt)
alert("Equal");
else
alert("Not Equal");
Try It
Posted By - | Karan Gupta |
|
Posted On - | Sunday, January 15, 2017 |