home ~ projects ~ socials

Move An Item From The Front Of An Array To The Back

#+KEYWORDS: splice shuffle

const letters = ['a', 'b', 'c', 'd', 'e']

  letters.push(letters.splice(0, 1)[0])

  console.log(letters)
Output:
[ 'b', 'c', 'd', 'e', 'a' ]
-- end of line --