JS: Array.prototype.shift
xArray.shift()-
- Remove and return the first item.
- If xArray is empty, return undefined.
// example of shift const xx = ["a", "b", "c"]; const yy = xx.shift(); console.log(yy); // a // original changed console.log(xx); // [ "b", "c" ] // shift on empty array return undefined const xx = []; const yy = xx.shift(); console.assert(yy === undefined);