Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following JavaScript code?
var values=[“one”,”two”,”Three”];
var ans=values.shift();
document.writeln(ans);

What will be the output of the following JavaScript code?
var values=[“one”,”two”,”Three”];
var ans=values.shift();
document.writeln(ans);
a) one
b) two
c) three
d) error

Answer: a
Explanation: shift is a predefined function in array library and works like a pop function. It pops the first value of the array and returns its value. Therefore the answer will be one.

Join The Discussion