- A Prints an exception error
- B Prints an overflow error
- C Displays "Infinity"
- D Prints the value as such
- Share this MCQ
In JavaScript, if the result of an arithmetic operation is larger than the largest representable number,
the result will be positive infinity.
Similarly, if the result of an arithmetic operation is smaller than the smallest representable negative number,
the result will be negative infinity.
For example, consider the following code:
let x = 1.7976931348623157e+308;
let y = x * 2;
console.log(y); // prints "Infinity"
let a = -1.7976931348623157e+308;
let b = a * 2;
console.log(b); // prints "-Infinity"
In this example, the variables x and a are assigned the largest and smallest representable numbers, respectively.
When these numbers are multiplied by 2, the result is positive and negative infinity, respectively.
Share this MCQ