Wednesday, 21 August 2013

Remove value from array in Underscore

Remove value from array in Underscore

Why isn't there a super simple remove function in underscore?
var arr = [1,2,3,4,5];
_.remove(arr, 5);
Sure I could use reject or without... but neither of them are destructive.
Am I missing something?
I guess I'll do it the old fashioned way...
arr.splice(arr.indexOf(5), 1);
ugh

No comments:

Post a Comment