Js how to traverse the map type


  1, forEach iterate:

          map.forEach (function (value, Key) {
            the console.log (value, Key);
          });
     function first parameter is the attribute value, the second parameter is a property

  2, for-of traverse:
        ①for (Item of the let Map) {

         }
     traversal result is an array
        ②for (map.values of the let Item ()) {

         }
     traversal attribute value
        ③for (map.keys of the let Item ()) {

         }
     traversal properties

  3, entries traversal:

        for (map.entries of the let Item ()) {

        }
     through the results with forEach

Guess you like

Origin www.cnblogs.com/wuqilang/p/11204656.html