1. What types of numbers does JavaScript support?
Answer:
Explanation:
JavaScript has only one type of number, which can be written with or without decimals, including integers and floating-point numbers.
2. How are JavaScript numbers stored internally?
Answer:
Explanation:
JavaScript numbers are always stored as double precision floating point numbers (64-bit), following the international IEEE 754 standard.
3. What is the precision limit of integers in JavaScript?
Answer:
Explanation:
Integers in JavaScript are accurate up to 15 digits.
4. Which of the following demonstrates JavaScript's floating point arithmetic inaccuracy?
Answer:
Explanation:
Floating point arithmetic in JavaScript is not always 100% accurate. For example, 0.1 + 0.2 does not precisely equal 0.3 due to the way floating-point numbers are represented in the language.
5. What is the result of adding a number and a string in JavaScript?
Answer:
Explanation:
In JavaScript, using the + operator between a number and a string results in string concatenation.
6. What does the JavaScript operation 100 / "Apple" return?
Answer:
Explanation:
Performing arithmetic operations with non-numeric strings in JavaScript, like 100 / "Apple", results in NaN (Not a Number).
7. What is the output of typeof NaN in JavaScript?
Answer:
Explanation:
In JavaScript, the typeof NaN returns "number", indicating that NaN, while representing 'Not a Number', is technically of the type number.
8. What value does JavaScript return when performing calculations exceeding the largest representable number?
Answer:
Explanation:
JavaScript returns 'Infinity' when calculations exceed the largest possible number, such as division by zero or exceedingly large exponentiations.
9. How does JavaScript interpret numeric constants preceded by "0x"?
Answer:
Explanation:
Numeric constants preceded by "0x" are interpreted as hexadecimal numbers in JavaScript.
10. What is the result of using new Number(123) in JavaScript?
Answer:
Explanation:
Using new Number(123) creates a Number object, which is different from a number primitive. Number objects can produce unexpected results compared to number primitives.
11. What happens when you add two numeric strings in JavaScript?
Answer:
Explanation:
When adding two numeric strings in JavaScript, the strings are concatenated instead of being added as numbers.
12. How can you check if a value is NaN in JavaScript?
Answer:
Explanation:
The global JavaScript function isNaN() is used to determine if a value is NaN.
13. What is the maximum number of decimals that JavaScript can handle in a number?
Answer:
Explanation:
The maximum number of decimals JavaScript can handle in a number is 17.
14. In JavaScript, what is the result of dividing a number by zero?
Answer:
Explanation:
Dividing a number by zero in JavaScript results in Infinity.
15. How does JavaScript handle hexadecimal number representation?
Answer:
Explanation:
In JavaScript, hexadecimal numbers are represented by prefixing them with "0x".