Software Development Exam  >  Software Development Tests  >  Test: Arrays in JS - 2 - Software Development MCQ

Test: Arrays in JS - 2 - Software Development MCQ


Test Description

15 Questions MCQ Test - Test: Arrays in JS - 2

Test: Arrays in JS - 2 for Software Development 2024 is part of Software Development preparation. The Test: Arrays in JS - 2 questions and answers have been prepared according to the Software Development exam syllabus.The Test: Arrays in JS - 2 MCQs are made for Software Development 2024 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests for Test: Arrays in JS - 2 below.
Solutions of Test: Arrays in JS - 2 questions in English are available as part of our course for Software Development & Test: Arrays in JS - 2 solutions in Hindi for Software Development course. Download more important topics, notes, lectures and mock test series for Software Development Exam by signing up for free. Attempt Test: Arrays in JS - 2 | 15 questions in 30 minutes | Mock test for Software Development preparation | Free important questions MCQ to study for Software Development Exam | Download free PDF with solutions
Test: Arrays in JS - 2 - Question 1

Which of the following methods can be used to add elements to the end of an array in JavaScript?

Detailed Solution for Test: Arrays in JS - 2 - Question 1

The 'push()' method is used to add elements to the end of an array.

Test: Arrays in JS - 2 - Question 2

What does the 'indexOf()' method in JavaScript return if the element is not found in the array?

Detailed Solution for Test: Arrays in JS - 2 - Question 2

The 'indexOf()' method returns -1 if the element is not found in the array.

1 Crore+ students have signed up on EduRev. Have you? Download the App
Test: Arrays in JS - 2 - Question 3

Which of the following methods can be used to remove elements from an array in JavaScript?

Detailed Solution for Test: Arrays in JS - 2 - Question 3

The 'splice()' method can be used to remove elements from an array.

Test: Arrays in JS - 2 - Question 4

What is the result of the following code snippet?
let arr = [1, 2, 3, 4, 5];
arr.splice(1, 2);
console.log(arr.length);

Detailed Solution for Test: Arrays in JS - 2 - Question 4

The 'splice()' method removes 2 elements starting from the index 1, so the resulting array has 3 elements.

Test: Arrays in JS - 2 - Question 5

Which method is used to create a new array with the results of calling a provided function on every element in the calling array?

Detailed Solution for Test: Arrays in JS - 2 - Question 5

The 'map()' method creates a new array with the results of calling a provided function on every element in the calling array.

Test: Arrays in JS - 2 - Question 6

What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.pop());

Detailed Solution for Test: Arrays in JS - 2 - Question 6

The 'pop()' method removes the last element from the array and returns it. In this case, it removes 5 from the array and returns it.

Test: Arrays in JS - 2 - Question 7

What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.shift());

Detailed Solution for Test: Arrays in JS - 2 - Question 7

The 'shift()' method removes the first element from the array and returns it. In this case, it removes 1 from the array and returns it.

Test: Arrays in JS - 2 - Question 8

What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.slice(1, 3));

Detailed Solution for Test: Arrays in JS - 2 - Question 8

The 'slice()' method returns a new array containing the elements from index 1 (inclusive) to index 3 (exclusive). In this case, it returns [2, 3].

Test: Arrays in JS - 2 - Question 9

What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.concat([6, 7]));

Detailed Solution for Test: Arrays in JS - 2 - Question 9

The 'concat()' method is used to merge two or more arrays. It returns a new array that contains the elements of the original array followed by the elements of the provided arrays.

Test: Arrays in JS - 2 - Question 10

What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.join("-"));

Detailed Solution for Test: Arrays in JS - 2 - Question 10

The 'join()' method converts all the elements of an array into a string and concatenates them, using the specified separator (in this case, "-").

Test: Arrays in JS - 2 - Question 11

What is the output of the following code snippet?
 

```javascript
let arr = [1, 2, 3, 4, 5];
let doubledArr = arr.map((num) => num * 2);
console.log(doubledArr);
```

Detailed Solution for Test: Arrays in JS - 2 - Question 11

The 'map()' method creates a new array by applying a provided function to each element of the original array. In this case, the function doubles each element of the array.

Test: Arrays in JS - 2 - Question 12

What is the output of the following code snippet?
```javascript
let arr = [1, 2, 3, 4, 5];
let filteredArr = arr.filter((num) => num % 2 === 0);
console.log(filteredArr);
```

Detailed Solution for Test: Arrays in JS - 2 - Question 12

The 'filter()' method creates a new array with all elements that pass the test implemented by the provided function. In this case, the function filters out the odd numbers from the array.

Test: Arrays in JS - 2 - Question 13

What is the output of the following code snippet?
```javascript
let arr = [1, 2, 3, 4, 5];
let sum = arr.reduce((total, num) => total + num, 0);
console.log(sum);
```

Detailed Solution for Test: Arrays in JS - 2 - Question 13

The 'reduce()' method applies a provided function to reduce the array to a single value. In this case, the function calculates the sum of all elements in the array.

Test: Arrays in JS - 2 - Question 14

What is the output of the following code snippet?
```javascript
let arr = [1, 2, 3, 4, 5];
let includes = arr.includes(3);
console.log(includes);
```

Detailed Solution for Test: Arrays in JS - 2 - Question 14

The 'includes()' method checks if a specific element is present in the array. It returns 'true' if the element is found, otherwise 'false'.

Test: Arrays in JS - 2 - Question 15

What is the output of the following code snippet?
```javascript
let arr = [1, 2, 3, 4, 5];
let index = arr.findIndex((num) => num === 3);
console.log(index);
```

Detailed Solution for Test: Arrays in JS - 2 - Question 15

The 'findIndex()' method returns the index of the first element in the array that satisfies the provided testing function. In this case, it returns the index of the element 3.

Information about Test: Arrays in JS - 2 Page
In this test you can find the Exam questions for Test: Arrays in JS - 2 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Arrays in JS - 2, EduRev gives you an ample number of Online tests for practice

Top Courses for Software Development

Download as PDF

Top Courses for Software Development