Array.prototype.shiftintermediateconst words = ['hello', 'world', 'foo']
const head = words.shift() // β 'hello'
words // β ['world', 'foo']Use shift() to consume the first element of a word or message queue.
Use shift() to consume and process the first element of a list one at a time β a common pattern in command parsing or token processing.
const words = ['hello', 'world']
const first = words.shift() // 'hello', words === ['world']