3.3.1 Arrays in JavaScript

10 Computer Science · Chapter 3: Programing Fundamentals · Federal Board (FBISE)

3.3.1 Arrays in JavaScript from Federal Board 10 Computer Science (10th Class) Chapter 3, Programing Fundamentals: 6 short and long questions and 8 MCQs with answers.

Arrays in JavaScript MCQs

  1. Q1

    What is the index of the first element in a JavaScript array?

    1. A0
    2. B-1
    3. C1
    4. DIt depends on the array
    Show answer

    Correct answer: A. 0

    JavaScript array indexing starts at 0, so the first element has index 0.

  2. Q2

    Which function is used to add an item to the end of a JavaScript array?

    1. Apop()
    2. Bshift()
    3. Cpush()
    4. Dunshift()
    Show answer

    Correct answer: C. push()

    The push() function adds a new item at the end of an array.

  3. Q3

    Which function removes an item from the end of a JavaScript array?

    1. AindexOf()
    2. Bpop()
    3. Cpush()
    4. Dconcat()
    Show answer

    Correct answer: B. pop()

    The pop() function removes the last item from an array.

  4. Q4

    What does the indexOf() function do when applied to an array?

    1. AConverts the array to a string
    2. BMerges two arrays
    3. CReturns the index where a given element is found
    4. DRemoves an element
    Show answer

    Correct answer: C. Returns the index where a given element is found

    indexOf() searches for a given element and returns the index number where it is found.

  5. Q5

    Which function merges two JavaScript arrays into one?

    1. Aslice()
    2. BtoString()
    3. Cconcat()
    4. Dpush()
    Show answer

    Correct answer: C. concat()

    The concat() function merges two arrays together.

  6. Q6

    What does the slice() function do to an array?

    1. ACreates a new subset array from the original
    2. BDeletes the entire array
    3. CConverts the array to a string
    4. DSorts the array
    Show answer

    Correct answer: A. Creates a new subset array from the original

    slice() creates a new subset array taken from a portion of the original array.

  7. Q7

    In JavaScript, which method would you use to add a new item to the end of a list?

    1. Aleftshift()
    2. Bpush()
    3. Cadd()
    4. Drightshift()
    Show answer

    Correct answer: B. push()

    The push() method adds a new item to the end of a JavaScript array.

  8. Q8

    In JavaScript, how do you access the third element in an array called myArray?

    1. AmyArray[2]
    2. BmyArray[1]
    3. CmyArray[3]
    4. DmyArray[0]
    Show answer

    Correct answer: A. myArray[2]

    Since array indexing starts at 0, the third element is accessed using index 2.

Arrays in JavaScript short questions

  1. What is the role of JavaScript in making websites dynamic?

    Important
  2. Explain a program (with code) that calculates the sum of the first 10 integers.

    Important
  3. Find the error(s) in the following code snippets.

    Important
  4. What is a JavaScript array?

  5. Explain the push() and pop() functions with examples.

Arrays in JavaScript long questions

  1. What is a JavaScript array? Explain its common functions with examples, and describe a program that calculates the sum of the first 10 integers using an array.

Chapter 3 study material

A little trouble connecting

We could not reach IlmiDunya. Your connection may be slow or interrupted. Check your connection and try again.

If you were saving or submitting, check the result before trying again.

Account blocked

You are blocked from using IlmiDunya. Contact support to unblock your account.