JavaScript Implicit Boolean Conversion to Number
In Boolean true is 1, false is 0
let num;
num = '4' - true;
console.log(num); // 3
num = 4 + true;
console.log(num); // 5
num = 4 + false;
console.log(num); // 4
Comments
Post a Comment