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
- Q1
What is the index of the first element in a JavaScript array?
Show answer
Correct answer: A. 0
JavaScript array indexing starts at 0, so the first element has index 0.
- Q2
Which function is used to add an item to the end of a JavaScript array?
Show answer
Correct answer: C. push()
The push() function adds a new item at the end of an array.
- Q3
Which function removes an item from the end of a JavaScript array?
Show answer
Correct answer: B. pop()
The pop() function removes the last item from an array.
- Q4
What does the indexOf() function do when applied to an array?
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.
- Q5
Which function merges two JavaScript arrays into one?
Show answer
Correct answer: C. concat()
The concat() function merges two arrays together.
- Q6
What does the slice() function do to an 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.
- Q7
In JavaScript, which method would you use to add a new item to the end of a list?
Show answer
Correct answer: B. push()
The push() method adds a new item to the end of a JavaScript array.
- Q8
In JavaScript, how do you access the third element in an array called myArray?
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
What is the role of JavaScript in making websites dynamic?
ImportantExplain a program (with code) that calculates the sum of the first 10 integers.
ImportantFind the error(s) in the following code snippets.
ImportantWhat is a JavaScript array?
Explain the push() and pop() functions with examples.
Arrays in JavaScript long questions
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.