0 votes
in JavaScript by (19.9k points)
Which one of the following options is the correct output for the given code of javascript?

var values=[4,5,6,7]  



a) Error

b) 5, 6, 7

c) 4, 5, 6,

d) 4, 5, 6, 7

1 Answer

0 votes
by (23.1k points)

Answer: A

Explanation: The "slice()" method used in the above program a built-in function of the JavaScript and it is used to delete/remove the data items from the array. In general, it requires two arguments,in which first one for starting point and another one for the ending point. For example, consider the following given code:

function myFunction() {
  var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"];
  var myBest = fruits.slice(-3, -1);
document.getElementById("demo").innerHTML = myBest;



However, we can see that in given question only one argument is passed, so it will definitely result in an error.

Related questions