gpt4 book ai didi

immutable.js 从 map/hash 中获取键

转载 作者:行者123 更新时间:2023-12-03 11:31:06 24 4
gpt4 key购买 nike

我想从以下不可变映射中检索 keys():

var map = Immutable.fromJS({"firstKey": null, "secondKey": null });
console.log(JSON.stringify(map.keys()));

我希望输出:
["firstKey", "secondKey"]

然而,这输出:
{"_type":0,"_stack":{"node":{"ownerID":{},"entries":[["firstKey",null],["secondKey",null]]},"index":0}}

如何正确操作?

JSFiddle 链接: https://jsfiddle.net/o04btr3j/57/

最佳答案

虽然这个问题在不久前得到了回答,但这里有一点更新:

ES6 解决方案:

const [ ...keys ] = map.keys();

ES6 前解决方案:
var keys = map.keySeq().toArray();

关于immutable.js 从 map/hash 中获取键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35623347/

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