简体   繁体   中英

How to delete an element from an array which is inside an object in ImmutableJS

if i have an object like so:

var fruitList = Immutable.map ({ fruits: [apples, oranges, mangoes]});

How do i delete one of the element of the array while maintaining immutability.

var newList = {fruits: [apples, oranges]};

您可以尝试以下方法:

var newList = fruitList.get('fruits').delete(fruitList.get('fruits').findIndex(fruit => fruit === 'mangoes'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM