(function(){
var a = b = 5;
})();
console.log(b);
Expected Output:
5
Follow-Up Questions:
b exist outside the IIFE (Immediately Invoked Function Expression)?var, let, or const affect scope?a and b in this context?Explanation:
var a = b = 5; assigns 5 to b and then assigns b to a. However, b is not declared with var, let, or const, making it a global variable.a is function-scoped due to var, so it is not accessible outside the IIFE.b outside the function logs 5 because it becomes a property of the global object.console.log(0.1 + 0.2 === 0.3);
Expected Output:
false
Follow-Up Questions:
false when mathematically it should be true?