gpt4 book ai didi

javascript - ImmutableJS - 从 map 中删除元素

转载 作者:可可西里 更新时间:2023-11-01 01:24:11 26 4
gpt4 key购买 nike

我有一个具有这种结构的 map :

{
1: {},
2: {}
}

我想从中删除 2: {}(当然 - 返回没有这个的新集合)。我该怎么做?我试过了,但出了点问题:

 theFormerMap.deleteIn([],2) //[] should mean that it's right in the root of the map, and 2 is the name of the object I want to get rid of

最佳答案

只需使用delete方法和双引号中的属性:

theFormerMap = theFormerMap.delete("2")

关于javascript - ImmutableJS - 从 map 中删除元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31128425/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com