What will the console.log(0.1 + 0.2 === 0.3) statement output?

What will the console.log(0.1 + 0.2 === 0.3) statement output?

a) true
b) false
c) undefined
d) NaN

Answer:

b) false

Explanation:

In JavaScript, the expression 0.1 + 0.2 === 0.3 evaluates to false due to floating-point precision issues. JavaScript uses floating-point arithmetic, which cannot precisely represent some decimal numbers, leading to small errors in calculations.

Reference:

JavaScript MCQ (Multiple-Choice Questions)

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top