Logo

Programming-Idioms

History of Idiom 135 > diff from v18 to v19

Edit summary for version 19 by test:
[JS] test

Version 18

2019-09-26, 16:23:13

Version 19

2019-09-26, 16:34:48

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Idiom #135 Remove item from list, by its value

Remove at most 1 item from list items, having value x.
This will alter the original list or return a new list, depending on which is more idiomatic. If there are several occurrences of x in items, remove only one of them.

Code
items = items.filter(i => i !== val);
Code
items = items.filter(i => i !== val);
Comments bubble
This returns a new list without the item
Comments bubble
This returns a new list without the item
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
Doc URL
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter