shift

shift

> Functions

Removes the first element of the array array and returns that 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 check the length before calling it.

Python

Python has 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. Mind the cost: a.pop(0) shifts the whole list on every call. For a queue, collections.deque and its popleft() are made for this.