An ES6 array of numbers - Double last number, delete the first number
This will be cleaner if you implement it as a pure function, which takes the sequence as an argument.  You can make [1, 2, 4, 8, 16] a default value for that argument, so that you can start the sequence with nothing.  Taking this approach, the function simplifies to:

function updateSequence(arr = updateSequence.default) {
  const last = arr[arr.length-1]
  if (last == 32768) return updateSequence.default

  const ret = arr.concat(last * 2)
  return ret.length &gt; 10 ? ret.slice(1) : ret
}
updateSequence.default = [1, 2, 4, 8, 16]


You can test that it works like this:

// test it
var arr = updateSequence()
for (i=0; i&lt;15; i++) {
  console.log(arr)
  arr = updateSequence(arr)
}


which prints the following:

[ 1, 2, 4, 8, 16, 32 ]
[ 1, 2, 4, 8, 16, 32, 64 ]
[ 1, 2, 4, 8, 16, 32, 64, 128 ]
[ 1, 2, 4, 8, 16, 32, 64, 128, 256 ]
[ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 ]
[ 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 ]
[ 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 ]
[ 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 ]
[ 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 ]
[ 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384 ]
[ 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 ]
[ 1, 2, 4, 8, 16 ]
[ 1, 2, 4, 8, 16, 32 ]
[ 1, 2, 4, 8, 16, 32, 64 ]
[ 1, 2, 4, 8, 16, 32, 64, 128 ]