There is an array that we will refer to as collection
.
If the array has only one element, for example [5]
, then collection.slice(-1)
will return [5]
.
But strangely enough, if you try collection.slice(0,-1)
, it will give you an empty array: []
.
Have you ever wondered why this difference occurs?