Explicit conversion true false!?

var k = true-false;
console.log(k,typeof(k));

var k = true+2;
console.log(k,typeof(k));

var k = true-3;
console.log(k,typeof(k));
k =" false"-4;
console.log(k,typeof(k));

var k = -3+true;
console.log(k,typeof(k));

find out the answer…???

3 Likes

Hi, thank you for posting the doubt here. Give us some time and we’ll respond shortly with a resolution.

1 Like
var k = true-false;
console.log(k,typeof(k));
//1, number
var k = true+2;
console.log(k,typeof(k));
//3,number

var k = true-3;
console.log(k,typeof(k));
//-2,number
k =" false"-4;
console.log(k,typeof(k));
//NaN.number
var k = -3+true;
console.log(k,typeof(k));
//-2,number
1 Like