What does the JavaScript expression 5 === "5" evaluate to?
03 Types and Data Representation Online Quiz Questions
Use this free practice quiz with 20 questions to review 03 Types and Data Representation, test your knowledge, and prepare for your next test or exam.
What string does JavaScript return for typeof null?
- A
"object"
- B
"null"
- C
"undefined"
- D
"value"
A program needs to store tags while automatically eliminating duplicate tag values. Which JavaScript representation is the best fit?
- A
An array
- B
An object
- C
A set
- D
A string
Which expression correctly tests whether names was created as an array using the Array constructor or its prototype chain?
- A
names instanceof Array - B
names is Array - C
Array.typeof(names) - D
names.constructorCheck(Array)
In JavaScript, calling toUpperCase() on a string changes the original string in place.
- A
True
- B
False
In JavaScript, ordinary floating-point numbers represent every decimal calculation exactly, so 0.1 + 0.2 always produces exactly 0.3.
- A
True
- B
False
What numeric index accesses the first character of the JavaScript string "Hello"?
What special JavaScript numeric value is produced by Number("not a number")?
To convert the decimal text "3.14" to a floating-point number using the conversion function shown in the material, call ("3.14").
A named property in a JavaScript object can be accessed with or .
Select all statements that correctly describe JavaScript value assignment and object copying.
- A
After
let a = 10; let b = a;, assigningb = 20leavesaequal to 10. - B
After
const first = { score: 10 }; const second = first;, changingsecond.scorealso changes the value seen throughfirst. - C
A shallow copy of an object does not recursively copy nested objects or arrays.
- D
Assigning one object variable to another always creates an independent copy of every nested property.
Select all statements that correctly describe JSON serialization and parsing across a program boundary.
- A
JSON.stringify()converts an in-memory object or array into JSON text. - B
JSON.parse()converts JSON text back into a JavaScript value. - C
Data parsed from an external source should be validated before the program relies on its shape.
- D
JSON.parse()automatically guarantees that every property has the type the application expects.
A form supplies quantity = "10" and price = "5" as strings. Explain how you would safely prepare these values for numeric addition in JavaScript, including how you would handle invalid input and why adding the original strings is unsafe.
Which JavaScript data representation is most appropriate for storing the steps of a recipe in their required order?
- A
Set
- B
Array
- C
Map
- D
Object
A form field supplies the string value "5". What does 5 === "5" evaluate to, and why?
- A
true, because both display as 5
- B
true, because JavaScript converts the string automatically
- C
false, because strict equality does not convert the string
- D
false, because numbers cannot be compared with strings
A function must accept either an array or an ordinary object. Which check correctly identifies whether the received value is an array?
- A
typeof value === "array" - B
value instanceof String - C
value === null - D
Array.isArray(value)
True or false: After let word = "cat"; word.toUpperCase();, the value of word is "CAT".
- A
True
- B
False
What JavaScript operator would you use to check whether an object belongs to a constructor's prototype chain, such as whether names is an instance of Array?
A program needs to associate each user object with that user's latest score, using the user object itself as a key. Which JavaScript representation best fits this requirement?
- A
Array, because it always provides the fastest key lookup
- B
Set, because it stores one value for each key
- C
Map, because it stores key-value associations and supports many key types
- D
String, because text is the most flexible representation
A program has a numeric user ID stored in userId and must explicitly convert it to a string before passing it to a text-processing function. Which JavaScript conversion function should it use?