array.slice(-1)[0] -- Can someone explain?

Viewed 5734

I got this code from codeblocq.com (never heard of the site):

alert(array.slice(-1)[0]);

It somehow returns the value of the last element in array. The code works just as it should, but I have no idea how. Could anyone please help me understand this sorcery?

3 Answers
Related