JS-Dev-101 practice question 19 of 25
Refer to the code: const pi = 3.1415926; What is the data type of pi?
Full set: 148 questionsJavaScript has only one type of number, which is Number. Unlike other programming languages, it does not have distinct types for integers, floats, doubles, or decimals. All numbers are implemented as 64-bit floating-point values according to the IEEE 754 standard. The variable pi is assigned a floating-point literal, which falls under the Number primitive data type.
A. Float: This is a concept for a type of number, but it is not a distinct primitive data type in the JavaScript language itself.
B. Double: Similar to Float, this describes the precision of a number but is not a formal JavaScript data type. All numbers are effectively doubles.
C. Decimal: This is not a primitive data type in JavaScript. While there are libraries for handling high-precision decimals, it's not a native type.
1. MDN Web Docs, "JavaScript data types and data structures", Section: "Number type". States, "The Number numeric type has exactly one type: a double-precision 64-bit binary format IEEE 754 value... There is no specific integer type."
2. ECMAScript® 2024 Language Specification, Section 6.1.6, "The Number Type". Defines the Number type as representing all numbers using the "double-precision 64-bit format IEEE 754-2019 value".
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++) …
