Free Practice Quiz Question List

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.

20 questions
01
Choose one
1 point

What does the JavaScript expression 5 === "5" evaluate to?

  1. A

    true

  2. B

    false

  3. C

    undefined

  4. D

    null

02
Choose one
1 point

What string does JavaScript return for typeof null?

  1. A

    "object"

  2. B

    "null"

  3. C

    "undefined"

  4. D

    "value"

03
Choose one
1 point

A program needs to store tags while automatically eliminating duplicate tag values. Which JavaScript representation is the best fit?

  1. A

    An array

  2. B

    An object

  3. C

    A set

  4. D

    A string

04
Choose one
1 point

Which expression correctly tests whether names was created as an array using the Array constructor or its prototype chain?

  1. A

    names instanceof Array

  2. B

    names is Array

  3. C

    Array.typeof(names)

  4. D

    names.constructorCheck(Array)

05
True or false
1 point

In JavaScript, calling toUpperCase() on a string changes the original string in place.

  1. A

    True

  2. B

    False

06
True or false
1 point

In JavaScript, ordinary floating-point numbers represent every decimal calculation exactly, so 0.1 + 0.2 always produces exactly 0.3.

  1. A

    True

  2. B

    False

07
Written response
1 point

What numeric index accesses the first character of the JavaScript string "Hello"?

08
Written response
1 point

What special JavaScript numeric value is produced by Number("not a number")?

09
Fill in the blank
1 point

To convert the decimal text "3.14" to a floating-point number using the conversion function shown in the material, call ("3.14").

10
Fill in the blank
1 point

A named property in a JavaScript object can be accessed with or .

11
Choose all
1 point

Select all statements that correctly describe JavaScript value assignment and object copying.

  1. A

    After let a = 10; let b = a;, assigning b = 20 leaves a equal to 10.

  2. B

    After const first = { score: 10 }; const second = first;, changing second.score also changes the value seen through first.

  3. C

    A shallow copy of an object does not recursively copy nested objects or arrays.

  4. D

    Assigning one object variable to another always creates an independent copy of every nested property.

12
Choose all
1 point

Select all statements that correctly describe JSON serialization and parsing across a program boundary.

  1. A

    JSON.stringify() converts an in-memory object or array into JSON text.

  2. B

    JSON.parse() converts JSON text back into a JavaScript value.

  3. C

    Data parsed from an external source should be validated before the program relies on its shape.

  4. D

    JSON.parse() automatically guarantees that every property has the type the application expects.

13
Open ended
1 point

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.

14
Choose one
1 point

Which JavaScript data representation is most appropriate for storing the steps of a recipe in their required order?

  1. A

    Set

  2. B

    Array

  3. C

    Map

  4. D

    Object

15
Choose one
1 point

A form field supplies the string value "5". What does 5 === "5" evaluate to, and why?

  1. A

    true, because both display as 5

  2. B

    true, because JavaScript converts the string automatically

  3. C

    false, because strict equality does not convert the string

  4. D

    false, because numbers cannot be compared with strings

16
Choose one
1 point

A function must accept either an array or an ordinary object. Which check correctly identifies whether the received value is an array?

  1. A

    typeof value === "array"

  2. B

    value instanceof String

  3. C

    value === null

  4. D

    Array.isArray(value)

17
True or false
1 point

True or false: After let word = "cat"; word.toUpperCase();, the value of word is "CAT".

  1. A

    True

  2. B

    False

18
Written response
1 point

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?

19
Choose one
1 point

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?

  1. A

    Array, because it always provides the fastest key lookup

  2. B

    Set, because it stores one value for each key

  3. C

    Map, because it stores key-value associations and supports many key types

  4. D

    String, because text is the most flexible representation

20
Written response
1 point

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?