How to iterate (keys, values) in javascript?

前端 未结 10 2699
孤街浪徒
孤街浪徒 2020-11-27 09:23

I have a dictionary that has the format of

dictionary = {0: {object}, 1:{object}, 2:{object}}

How can I iterate through this dictionary by

10条回答
  •  执笔经年
    2020-11-27 10:08

    I think the fast and easy way is

    Object.entries(event).forEach(k => {
        console.log("properties ... ", k[0], k[1]); });
    

    just check the documentation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

提交回复
热议问题