DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
    • can-component
    • can-compute
    • can-connect
    • can-define
    • can-define/list/list
    • can-define/map/map
      • events
        • __keys
        • propertyName
      • static
        • extend
        • seal
      • prototype
        • forEach
        • get
        • on
        • serialize
        • set
        • *
    • can-route
    • can-route-pushstate
    • can-set
    • can-stache
    • can-stache/helpers/route
    • can-stache-bindings
  • Ecosystem
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Core
  • /
  • can-define/map/map
  • /
  • forEach
  • / On this page
    • forEach

      function

      Call a function on each property of a DefineMap.

      • source

      map.forEach( callback(value, propName ) )

      forEach iterates through the map instance, calling a function for each property value and key.

      map.forEach(function(value, propName){ ... });
      

      Parameters

      1. callback {function(value, propName)}:

        The function to call for each property The value and key of each property will be passed as the first and second arguments, respectively, to the callback. If the callback returns false, the loop will stop.

      Returns

      {can-define/map/map}:

      The map instance for chaining.

      Use

      Example

      var names = [];
      new DefineMap({a: 'Alice', b: 'Bob', e: 'Eve'}).forEach(function(value, key) {
          names.push(value);
      });
      
      names; // ['Alice', 'Bob', 'Eve']
      
      names = [];
      new DefineMap({a: 'Alice', b: 'Bob', e: 'Eve'}).forEach(function(value, key) {
          names.push(value);
          if(key === 'b') {
              return false;
          }
      });
      
      names; // ['Alice', 'Bob']
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.