Master Core JavaScript Data Structures

This quiz focuses on fundamental JavaScript data structures: Arrays, Objects, and their operations. You’ll explore key methods, access techniques, and manipulation strategies to strengthen your understanding.

Question 1.

Which of the following methods adds an element to the end of an array?

  • A.

    pop()

  • B.

    push()

  • C.

    unshift()

  • D.

    shift()

Question 2.

How can you access the value 3 from the following array?

  • A.

    arr[2][0]

  • B.

    arr[2][1]

  • C.

    arr[1][0]

  • D.

    arr[0][2]

Question 3.

What does Object.keys() return?

  • A.

    An array of object keys

  • B.

    An array of object values

  • C.

    A string of keys

  • D.

    undefined

Question 4.

What is the output of arr.length after this code?

  • A.

    3

  • B.

    5

  • C.

    6

  • D.

    undefined

Question 5.

What does arr.slice(1, 3) return for arr = [10, 20, 30, 40]?

  • A.

    [10, 20]

  • B.

    [20, 30]

  • C.

    [30,40]

  • D.

    [20, 30, 40]

Question 6.

Which of these is true about objects in JavaScript?

  • A.

    Keys can only be strings.

  • B.

    Values must be primitives.

  • C.

    They are unordered collections of key-value pairs.

  • D.

    They cannot have nested structures.

Question 7.

How can you combine two arrays, arr1 and arr2, without modifying them?

  • A.

    arr1.concat(arr2)

  • B.

    arr1.push(arr2)

  • C.

    arr1.join(arr2)

  • D.

    arr1.splice(arr2)

Question 8.

What does delete obj.key do?

  • A.

    Removes the key-value pair from the object.

  • B.

    Sets the value to null.

  • C.

    Sets the value to undefined.

  • D.

    Throws an error.

Question 9.

Which method converts an array into a string with a specified separator?

  • A.

    join()

  • B.

    toString()

  • C.

    split()

  • D.

    concat()

Question 10.

What will below code do?

  • A.

    Add a property key1 with value 'value' and key2 with 'value2'.

  • B.

    Add a property key1 with value 'value' but throw an error for key2.

  • C.

    Throw an error because objects are immutable.

  • D.

    None of the above.