$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #152

What is the output?

console.log([1, 2, 3].slice(-1));
  1. [ 3 ]
  2. [ 1 ]
  3. [ 2, 3 ]
  4. []
A negative start counts from the end, so slice(-1) takes the last element.
Play Problem Solving ▸