QuestenaUn entraînement qui indique quoi revoir ensuite
Question 112

Without any explicit conversion, what happens when JavaScript evaluates 1n + 1?

  1. It returns the Number 2
  2. It returns the BigInt 2n
  3. It returns NaN
  4. It throws a TypeErrorBonne réponse

Explication

The addition mixes a BigInt operand with a Number operand, and direct arithmetic between those numeric types throws a TypeError. It does not silently convert both operands; an explicit conversion would be needed to make their numeric types agree.

Continuer avec ce test

Commencer l’entraînement
Question 112: Without any explicit conversion, what happens when… · JavaScript Fundamentals · Questena