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 possible output of the following JavaScript code?
var a = [1,2,3,4,5];
a.slice(0,3);

What will be the possible output of the following JavaScript code?
var a = [1,2,3,4,5];
a.slice(0,3);
a) Returns [1,2,3]
b) Returns [4,5]
c) Returns [1,2,3,4]
d) Returns [1,2,3,4,5]

Answer: a
Explanation: .slice() function is a predefined function in JavaScript used to keep the elements from starting point and ending point mentioned in the function argument. The elements after the ending point and before the starting point are not shown.

Join The Discussion