shift

shift

> Functions

Removes the first slot of the array array and returns the corresponding element.

Parameters
Return
TypeScript

In JavaScript, a.shift() returns undefined on an empty array, where shift in LeekScript reports an error in the log and returns null: test === undefined, or the length before calling.

Python

In Python there is no shift: a.pop(0) removes and returns the first element. On an empty list it raises an IndexError, where shift in LeekScript reports an error in the log and returns null. Beware of the cost: a.pop(0) shifts the whole list on every call. For a queue, collections.deque and its popleft() are made for that.