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
      • events
        • add
        • length
        • propertyName
        • remove
      • prototype
        • concat
        • filter
        • forEach
        • get
        • indexOf
        • join
        • map
        • on
        • pop
        • push
        • replace
        • reverse
        • serialize
        • set
        • shift
        • slice
        • sort
        • splice
        • unshift
        • *
        • #
      • static
        • extend
    • can-define/map/map
    • 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/list/list
  • /
  • map
  • / On this page
    • map

      function

      Map the values in this list to another list.

      • source

      list.map(callback[, thisArg])

      Loops through the values of the list, calling callback for each one until the list ends. The return values of callback are used to populate the returned list.

      var todos = new DefineList([
        {name: "dishes", complete: false},
        {name: "lawn", complete: true}
      ]);
      var names = todos.map(function(todo){
        return todo.name;
      });
      names //-> DefineList["dishes","lawn"]
      

      Parameters

      1. callback {function(item, index, list)}:

        A function to call with each element of the DefineList. The three parameters that callback gets passed are:

        • item - the element at index.
        • index - the current element of the list.
        • list - the DefineList the elements are coming from.

        The return value of callback, including undefined values are used to populated the resulting list.

      2. thisArg {Object}:

        The object to use as this inside the callback.

      Returns

      {can-define/list/list}:

      The list instance.

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