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

Popular posts from this blog

Inserting and Moving elements inside Ruby Array

Difference between Validations, Callbacks and Observers