Skip to content

Instantly share code, notes, and snippets.

@rxluz
Last active January 29, 2019 04:50
Show Gist options
  • Save rxluz/7439daeb6cf3601aeaf06503e3c15206 to your computer and use it in GitHub Desktop.
Save rxluz/7439daeb6cf3601aeaf06503e3c15206 to your computer and use it in GitHub Desktop.
JS Data Structures: Arrays, see more at: https://medium.com/p/e1bc57bda950
const animals = ['elephant', 'monkey', 'snake', 'lion']
const desiredPositionToRemove = 2
for (var index = desiredPositionToRemove; index < animals.length; index++) {
animals[index] = animals[index + 1]
}
animals.length = animals.length - 1
console.log(animals) // will return [ 'elephant', 'monkey', 'lion' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment