An empty string ("") evaluates to 0 by the unary plus operator and ~~ operator, while parseInt evaluates to NaN.
~~"" //Output - 0
+"" //Output - 0
parseInt("") //Ooutput - NaNparseInt builds and parses the string from left to right. While parsing if it gets an invalid or non-numnerical character it returns whatever has been parsed so far. On the contrary unary+ operator gives NaN and ~~ operator gives output as 0
~~"12rt" //Output - NaN
+"12rt" //Output - NaN
parseInt("12rt") //Ooutput - 12Conversion of undefined
~~null //Output - 0
+null //Output - 0
parseInt(null) //Ooutput - NaNConversion of undefined
~~undefined //Output - 0
+undefined //Output - NaN
parseInt(undefined) //Ooutput - NaNtypeof NaN //Number
123/0 //Infinity
var a = 123/0
typeof a //Number
isNaN("2") //false - JS internally tries to convert this to number using parseInt("2"). Values that are truthy or falsey
Any number is except 0 are true undefined, NaN, null is false
Infinity is true
Strings with characters are true but empty string is false
Implicit typecasting
var myString = "88";
var myNum = 88
if(myNum == myString){
console.log("mystring is equal to mynum");
}