Last active
December 25, 2017 14:58
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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