admin管理员组文章数量:1336568
Counting the items contained in an object, I used to have:
Object.keys(state.posts).length
Now, I have changed my posts
state into an immutablejs Map, like so:
Map({ "1": {title: "First Title"}, "2" : {title: "Second Title"} });
...but now I don't know how to count the items in the object anymore? I tried a few things like Object.keys(state.posts.get()).length
and Object.keys(state.posts.entries()).length
, but to no avail.
Counting the items contained in an object, I used to have:
Object.keys(state.posts).length
Now, I have changed my posts
state into an immutablejs Map, like so:
Map({ "1": {title: "First Title"}, "2" : {title: "Second Title"} });
...but now I don't know how to count the items in the object anymore? I tried a few things like Object.keys(state.posts.get()).length
and Object.keys(state.posts.entries()).length
, but to no avail.
2 Answers
Reset to default 6To get the size or length of ImmutableJS Map you can do:
state.posts.size
This is as documented on ImmutableJS Map#size
According to docs:
state.posts.count()
will always return proper size.
本文标签: javascriptCounting all items of an (ImmutableJS) MapStack Overflow
版权声明:本文标题:javascript - Counting all items of an (ImmutableJS) Map? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742410864a2469758.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论