Skip to content

Instantly share code, notes, and snippets.

@ElectricCoffee
Last active December 25, 2017 14:58
Show Gist options
  • Save ElectricCoffee/c7463bc2cbde9f18c0559a14c91a16af to your computer and use it in GitHub Desktop.
Save ElectricCoffee/c7463bc2cbde9f18c0559a14c91a16af to your computer and use it in GitHub Desktop.
A function similar to Python's array.pop(n). Give it an index, and it'll pick out the value stored within, removing it from the array
Array.prototype.pick = function(index) {
let element = this.splice(index, 1)
if (element == null || element.length == 0) {
return undefined
}
return element[0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment