javascript - Counting all items of an (ImmutableJS) Map? - Stack Overflow

Counting the items contained in an object, I used to have:Object.keys(state.posts).lengthNow, I have ch

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.

Share Improve this question asked Aug 1, 2017 at 0:42 George WelderGeorge Welder 4,05511 gold badges44 silver badges75 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

To 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742410864a4438784.html

相关推荐

  • javascript - Counting all items of an (ImmutableJS) Map? - Stack Overflow

    Counting the items contained in an object, I used to have:Object.keys(state.posts).lengthNow, I have ch

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信