Boolean(52) Boolean("52") Boolean(true) Boolean(function a(){}

All of these values are truthy values and will evaluate to true in a Boolean context, so if we put any of these values in this part of the if condition, then it would be treated as true and execute the if block, but which values would evaluate to false? Which values are false There are only 8 false values in JavaScript.

There are only 8 falsy values in JavaScript. Boolean(false) Boolean("") Boolean(NaN) Boolean(undefined) Boolean(null) Boolean(0n) Boolean(0) Boolean(-0)

These are the only values in JavaScript that are falsy and will evaluate to false in a Boolean context. Zero and negative zero are actually different values because if you use triple equals to check if these are different values.

0 === -0: triple equals are incorrect and tell that they both are the same. Triple equals is wrong because zero and negative zero are different, but if you divide something by 0, you get "infinity". If you divide something by negative zero then you get "negative infinity" and these will evaluate to different values or you could check for equality correctly by using the object.is(0,-0), you get false(both are not the same).

Both null and undefined represent the absence of a value, not a false value just the value doesn't exist. ! : It converts any value into Boolean and then flips it.

  1. If you put this in front of a truthy value, it will becomes false.
  2. If you put this in front of a false value, it will becomes true. !! : Which flip things twice. It turns truth value into true or false value into false. !true: true !false : false !"69" : true If you double the exclamation mark is equivalent to Boolean ("69") : true. It is a short way to check if the value is truthy or falsely value.

True --> 1 false --> 0

true+1 =2 False+1 =1 true3 =3 False3 = 0 Hello+world= Helloworld hello+5 = hello5 hello+true = hellotrue "2""2"= 4 truetrue =1 12รท"3" =4 "Ab"+"c" = Abc Ab"-"c" = Nan

Note: Type coercion could be unpredictable, so that's why you should generally avoid performing operations on values of different types unless you're sure about the type and the result, to find out what type coercion happens in different operations.

console.log(2 ==2 ); //true console.log(2 ==2 ==2 ); //false console.log(2 ==2 ==2 == 0 ); //true

console.log("5" - 2); //3 console.log("shiva" - 2); //Nan console.log(true - 2); // -1 console.log(true - 0); //1

  1. Equality with Type Coercion (==):

console.log(1 == '1'); // true