Last active
August 23, 2017 18:00
-
-
Save sergeliatko/51a83ae72b00787f9efd856683f98b32 to your computer and use it in GitHub Desktop.
Removes value from an 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
function removeValue( v, a ) { | |
if( a.length ) { | |
var i = a.indexOf(v); | |
if( -1 === i ) { | |
return a; | |
} | |
a.splice( i, 1 ); | |
return removeValue( v, a ); | |
} | |
return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or it can be done as an extension to an array prototype like this: