array.shift()
GIVEN calling shift()
on an array
WHEN shifting an empty array THEN undefined
is returned
WHEN shifting an array with one element
THEN the array is empty afterwards
THEN this one element is returned
GIVEN calling shift
on objects other than an array
WHEN calling shift
on an array-like object THEN it works like on an array
WHEN the array is created with a length of 0 THEN the value at index 0 does not get used
WHEN calling shift
on a string THEN this throws, because a string is immutable
Links
Very well readable, easy to understand description of how shift() works.
The version of the specification where `array.shift()` was introduced (PDF 723kB).