簡體   English   中英

如何從ImmutableJS中的對象內部的數組中刪除元素

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

如果我有這樣的對象:

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

我如何在保持不變性的同時刪除數組的元素之一。

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

您可以嘗試以下方法:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM