js如何遍历map类型


  1、forEach遍历:

          map.forEach(function(value,key){
            console.log(value,key);
          });
     函数中第一个参数是属性值,第二个参数是属性

  2、for-of遍历:
        ①for(let item of map){

         }
     遍历结果是数组
        ②for(let item of map.values()){

         }
     遍历属性值
        ③for(let item of map.keys()){

         }
     遍历属性

  3、entries遍历:

        for(let item of map.entries()){

        }
     遍历结果同forEach

原文地址:https://www.cnblogs.com/wuqilang/p/11204656.html