I have an array like this :
var array = [1,20,50,60,78,90];
var id = 50;
How can i remove the id from the array and return a new array that does not have the value of the id in new array?
I have an array like this :
var array = [1,20,50,60,78,90];
var id = 50;
How can i remove the id from the array and return a new array that does not have the value of the id in new array?
_filter works too. It's the opposite of _reject.
http://jsfiddle.net/kman007_us/WzaJz/5/
You can use splice, though it is not underscore's API:
In your example:
For the complex solutions you can use method
_.reject()
, so that you can put a custom logic into callback:For the simple cases use more convenient method
_.without()
:DEMO