1.

The pop() method of the array does which of the following task?(a) decrements the total length by 1(b) increments the total length by 1(c) prints the first element but no effect on the length(d) updates the elementI had been asked this question by my college director while I was bunking the class.I'd like to ask this question from Array and Related Methods topic in division Lexical Structures of JavaScript

Answer»

The correct CHOICE is (a) decrements the TOTAL LENGTH by 1

Easy explanation: pop() function pops out that is DELETE the last element from the array. Hence pop() method (it works with push()) reduces the length of an array by 1.



Discussion

No Comment Found

Related InterviewSolutions