1.

JavaScript _________ when there is an indefinite or an infinite value during an arithmetic computation.(a) Prints an exception error(b) Prints an overflow error(c) Displays “Infinity”(d) Prints the value as suchThis question was posed to me in an interview for internship.I need to ask this question from Types, Values and Variables topic in portion Lexical Structures of JavaScript

Answer»

Right answer is (c) DISPLAYSINFINITY

To explain: When the result of a numeric operation is larger than the largest representable NUMBER (overflow), JavaScript PRINTS the value as Infinity. Similarly, when a negative value becomes larger than the largest representable negative number, the result is negative infinity. The infinite values behave as you would expect: adding, subtracting, MULTIPLYING, or dividing them by anything results in an infinite value (possibly with the sign reversed).



Discussion

No Comment Found

Related InterviewSolutions