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
πŸ’¬ Discuss
βœ… Correct Answer: (B) 4, 3, 2, 1

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
πŸ’¬ Discuss
βœ… Correct Answer: (A) Error

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

  • (A) Typeof
  • (B) ==
  • (C) ===
  • (D) isarrayType()
πŸ’¬ Discuss
βœ… Correct Answer: (D) isarrayType()

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
πŸ’¬ Discuss
βœ… Correct Answer: (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

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
πŸ’¬ Discuss
βœ… Correct Answer: (A) inject and fold

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
πŸ’¬ Discuss
βœ… Correct Answer: (D) updates the element removes one element of an array on each time the "pop()" function called

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
πŸ’¬ Discuss
βœ… Correct Answer: (B) It will reverse the element and store the elements in the same array

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
πŸ’¬ Discuss
βœ… Correct Answer: (C) true false

Q. What will happen if we execute the following piece of code?

Code:
<script>  
  
var arr=[4,3,,1];    
  for(i=0;i<4;i++){  
document.writeln(arr[i]);  
}  
</script>  
  • (A) The output will be 4 3 1
  • (B) The output will be 4 3 undefined 1
  • (C) It will result in an error
  • (D) It does not run at all
πŸ’¬ Discuss
βœ… Correct Answer: (B) The output will be 4 3 undefined 1

Q. What output we may get if we execute the following JavaScript code

Code:
<script>  
function myFunction() {  
  
  var i;  
  for (i = 0; i< 5; i++) {  
    if (i === 3) {  
      continue;  
    }  
document.write(i);  
  }  
  
}  
myFunction();  
</script>  
  • (A) 0124
  • (B) 01234
  • (C) It will throw a error
  • (D) No output
πŸ’¬ Discuss
βœ… Correct Answer: (A) 0124