Question discussion

What is the output of the following JavaScript code?console.log(typeof null, 0.1 + 0.2 === 0.3, "5" - 2, "5" + 2);

958Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following JavaScript code?

console.log(typeof null, 0.1 + 0.2 === 0.3, "5" - 2, "5" + 2);
  • Anull true 3 52
  • Bobject false 3 7
  • Cobject false 3 52
  • Dobject true 3 52
Correct answer: C

Explanation

typeof null is "object"; 0.1 + 0.2 is not exactly 0.3 in floating point; "5" − 2 coerces to 3, while "5" + 2 concatenates to "52".

Discussion 0

Nobody has replied yet. Start the discussion!