let randomValue = { name: "Sagar" }
randomValue = 23
if (!typeof randomValue === "string") {
console.log("It's not a string!")
} else {
console.log("Yay it's a string!")
}
Answer is "Yay it's a String"
Let us know why
So basically is a JIT compiler right? it goes to first line sees randomValue has a object and then it is reassigned to 23 which is a number , basically typeof of randomValue is number right??
now we are having a check what happens is !typeOf randomValue which means !number so what number === true but !number === false right??
so when i am doing false==="string" it is false so if condition fails and console prints "Yay it's a String"
Thank you have a great day