Prepare for the Salesforce JavaScript Developer Exam. Utilize comprehensive quizzes, flashcards, and multiple choice questions with hints and explanations. Boost your exam readiness!

Practice this question and more.


What value does the statement '10 == "10"' evaluate to?

  1. true

  2. false

  3. undefined

  4. ReferenceError

The correct answer is: true

The statement '10 == "10"' evaluates to true because the equality operator (==) in JavaScript performs type coercion. In this case, JavaScript converts the string "10" into a number before comparing it to the number 10. After this conversion, both sides of the comparison become the number 10, leading to the equality check yielding true. Type coercion is a fundamental concept in JavaScript, where the language automatically converts values to the necessary type to perform the operation. In contrast, if the strict equality operator (===) were used, the comparison would check both value and type without conversion, resulting in a different outcome.