My Report

JavaScript Array Test


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. The reduce and reduceRight methods follow a common operation called __________

2. The method or operator used to identify the array is __________

3. What is the observation made in the following JavaScript code?

if (!a[i]) continue;

4. What will be the output of the following JavaScript code?

var val1=[1,2,3];  
var val2=[6,7,8];  
var result=val1.concat(val2);  
document.writeln(result); 

5. What is the observation made in the following JavaScript code?

var count = [1,,3]; 

6. What will be the shift() output of the following JavaScript code?

var a = []; 
a.unshift(1); 
a.unshift(22);
a.shift(); 
a.unshift(3,[4,5]); 
a.shift();
a.shift();
var output = a.shift();
document.writeln(output);

7. What will be the output of the following JavaScript code?

var values=["one","two","Three"];  
var ans=values.shift();  
document.writeln(ans);

8. The pop() method of the array does which of the following task?

9. The primary purpose of the array map() function is that it __________

10. What will happen if reverse() and join() methods are used simultaneously?

11. What will be the output of the following JavaScript code?

let sum=0;

var arr = [10,15,20,30];  
  
arr.forEach(function myFunction(element) 
{  
    	sum= sum+element;  
});  
document.writeln(sum);  

12. What will be the output of the following JavaScript code?

const array = [1, 2, 3, 4, 5];
const startIndex = 1;
const endIndex = 3;
const portionToReverse = array.slice(startIndex, endIndex + 1);
portionToReverse.reverse();

for (let i = startIndex, j = 0; i <= endIndex; i++, j++) {
    array[i] = portionToReverse[j];
}
console.log(array);  
document.writeln(rev);  

13. What will be the output of the following JavaScript code?

var values=[1,2,3,4]  
var ans=values.slice(1);  
document.writeln(ans);  

14. What will be the output of the following JavaScript code?

var a1 = [,,,]; 
var a2 = new Array(3); 
0 in a1 
0 in a2

15. What will be the possible output of the following JavaScript code?

var a = [1,2,3,4,5];
a.slice(0,3);

 

Start practicing “1000 MCQs on JavaScript”, and once you are ready, you can take tests on all topics by attempting our “JavaScript Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.