immutable.js #get如何工作? [英] How does immutable.js #get work?

查看:68
本文介绍了immutable.js #get如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Map()如何创建一个空的Map对象,但是get在这里如何工作?这是否意味着它将从active键中获取值,如果那里没有键,它将创建一个空的Map对象?文档在哪里?

I know how Map() can create an empty Map object, but how does the get here work?? Does it mean it will get get the value from the active key and if there isn't a key there, it will create an empty Map object? Where is the docs for this?

const activeSelector = createSelector(
  rootSelector,
  (root) => root.get('active', Map())
);

推荐答案

是的,这就是它的工作原理.在您的示例中,如果 active 不是键,它将返回一个新的Map.在文档中为 get() 定义>

Yes, that's how it works. In your example, if active is not a key, it will return a new Map. This is defined in the docs for get()

返回与提供的键关联的值;如果Collection不包含此键,则返回notSetValue.

Returns the value associated with the provided key, or notSetValue if the Collection does not contain this key.

这篇关于immutable.js #get如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆