JavaScript MCQs with answers Page - 12

Here, you will find a collection of MCQ questions on JavaScript. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 831.35K Points
Coach

Q. Which one of the following options is the correct output for the given code of java script?

Code:
var sum=0;  
   
vararr=[101,150,201,30];  
   
arr.forEach(functionmyFunction(element)  
{  
    sumsum=sum+element;  
});  
document.writeln(sum);  
  • (A) 70
  • (B) 75
  • (C) 482
  • (D) Error

A

Admin • 831.35K Points
Coach

Q. Which one of the following options is the correct output for the given code of JavaScript?

Code:
var values=["Three","two","one"];  
varans=values.shift();  
document.writeln(ans);  
  • (A) One
  • (B) two
  • (C) three
  • (D) error

A

Admin • 831.35K Points
Coach

Q. Which one of the following options is the correct output for the given code of JavaScript?

Code:
var arr=[4,3,2,1];  
var rev=arr.reverse();  
document.writeln(rev);  
  • (A) 1, 2, 3,4
  • (B) 4, 3, 2, 1
  • (C) 3
  • (D) 1

A

Admin • 831.35K Points
Coach

Q. Which one of the following options is the correct output for the given code of javascript?

Code:
var values=[4,5,6,7]  
varans=values.slice(1);  
document.writeln(ans);  
  • (A) Error
  • (B) 5, 6, 7
  • (C) 4, 5, 6,
  • (D) 4, 5, 6, 7

A

Admin • 831.35K Points
Coach

Q. Which one of the following method or operator is used for identification of the array?

  • (A) Typeof
  • (B) ==
  • (C) ===
  • (D) isarrayType()

A

Admin • 831.35K Points
Coach

Q. For which purpose the array "map()" methods is used ?

  • (A) It used for mapping the elements of another array into itself.
  • (B) It passes each data-item of the array and returns the necessary mapped elements
  • (C) It passes the data-items of an array into another array.
  • (D) It passes every element of the array on which it is invoked to the function you specify, and returns an array containing the values returned by that function

A

Admin • 831.35K Points
Coach

Q. Both the "rduucedRight()" and "reduce()" methods follow which one of the following common operation?

  • (A) inject and fold
  • (B) filter and fold
  • (C) finger and fold
  • (D) fold

A

Admin • 831.35K Points
Coach

Q. Which one of the following given task is performed by the "pop()" method of the array?

  • (A) It updates the element of the array
  • (B) it increments the total length of the array by 1
  • (C) It prints the first element and made no impact on the length of the array
  • (D) updates the element removes one element of an array on each time the "pop()" function called

A

Admin • 831.35K Points
Coach

Q. What will happen if we use the "join()" method along with the "reverse()" method?

  • (A) It will reverse and concatenates the elements of the array
  • (B) It will reverse the element and store the elements in the same array
  • (C) It will just reverse the element of the array
  • (D) It will store the elements of the specified array in the normal order

A

Admin • 831.35K Points
Coach

Q. What will be the output of the following given code of JavaScript?

Code:
var x1 =[,,,];  
var x2 =newArray(10);  
0in x1   
0in x2  
  • (A) true true
  • (B) false true
  • (C) true false
  • (D) false true

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ