Last active
May 16, 2016 21:21
-
-
Save renarsvilnis/b0fef6565d5c62e12826 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* ES6 way of removing nth array element in an immutable way | |
* @param [Array] arr | |
* @param [number] i | |
* @return [Array] | |
*/ | |
function removeNthEl (arr, i) { | |
return [ | |
...arr.slice(0, i), | |
...arr.slice(i + 1) | |
]; | |
}; | |
removeNthEl([1, 2, 3], 2); | |
// > [1, 2] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment