Which of the following methods can be used to add elements to the end of an array in JavaScript?
What does the 'indexOf()' method in JavaScript return if the element is not found in the array?
1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which of the following methods can be used to remove elements from an array in JavaScript?
What is the result of the following code snippet?
let arr = [1, 2, 3, 4, 5];
arr.splice(1, 2);
console.log(arr.length);
Which method is used to create a new array with the results of calling a provided function on every element in the calling array?
What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.pop());
What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.shift());
What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.slice(1, 3));
What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.concat([6, 7]));
What is the output of the following code snippet?
let arr = [1, 2, 3, 4, 5];
console.log(arr.join("-"));
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);
```
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);
```
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);
```
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);
```
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);
```
51 videos|28 docs|12 tests
|
51 videos|28 docs|12 tests
|