JS-Dev-101 practice question 16 of 25
Refer to the code below: const pi = 3.1415926; What is the data type of pi?
Full set: 148 questionsJavaScript has only one type for all numbers, both integers and floating-point values. This type is called Number. It is based on the IEEE 754 double-precision 64-bit binary format. While the value 3.1415926 is a floating-point number conceptually, its data type in JavaScript is simply Number. The language does not have distinct Float, Double, or Decimal primitive types.
B. Float is not a primitive data type in JavaScript. It's a concept used in other languages like Java or C++.
C. Double is not a primitive data type in JavaScript, although the Number type is implemented as a double-precision float.
D. Decimal is not a primitive data type in JavaScript. High-precision decimals require libraries like Decimal.js.
1. Mozilla Developer Network (MDN). (2023). JavaScript data types and data structures - Number type. "The Number numeric type represents both integer and floating-point numbers." Retrieved from developer.mozilla.org/en-US/docs/Web/JavaScript/Datastructures#numbertype.
2. ECMA-262, 15th edition, June 2024. 6.1.6.1 The Number Type. "The Number type has exactly 18437736874454810627 (that is, 2^64 - 2^53 + 3) values, representing the double-precision 64-bit format IEEE 754-2019 values..."
3. Stanford University, CS 101. JavaScript Numbers. "JavaScript has one number type: 64-bit floating point. There is no separate integer type."
Keep practicing
Take the free JS-Dev-101 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other JS-Dev-101 practice questions
- Question 1A developer executes: document.cookie; document.cookie = 'key=John Smith'; What is the be…
- Question 2A developer is required to write a function that calculates the sum of elements in an arr…
- Question 3Given the code below: 01 const delay = async delay => { 02 return new Promise((resolve, r…
- Question 401 function Animal(size, type) { 02 this.type = type || 'Animal'; 03 this.canTalk = false…
- Question 5Refer to the code snippet: 01 let array = [1, 2, 3, 4, 4, 5, 4, 4]; 02 for (let i = 0; i …
- Question 6Code: 01 let array = [1, 2, 3, 4, 4, 5, 4, 4]; 02 for (let i = 0; i < array.length; i++) …
