Reputation: 13716
Is it officially safe to:
someArray = someArray.filter(function(item) {
return item !== 'something';
});
I mean assigning back to the same array the filter function is called for, in one line. And same question for all other array prototype functions that return an array.
Upvotes: 3
Views: 887
Reputation: 12375
Yes, it's safe because it's returning the value from the function.
You should be careful about making sure you're reusing it correctly, though.
Upvotes: 3