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
  • /
  • get
  • / On this page
    • get

      function

      Gets an item or all items from a DefineList.

      • source

      list.get()

      Returns the list converted into a plain JS array. Any items that also have a get method will have their get method called and the resulting value will be used as item value.

      This can be used to recursively convert a list instance to an Array of other plain JavaScript objects. Cycles are supported and only create one object.

      get() can still return other non-plain JS objects like Dates. Use serialize when a form proper for JSON.stringify is needed.

      var list = new DefineList(["A","B"]);
      list.get() //-> ["A","B"]
      

      Returns

      {Array}:

      A plain JavaScript Array that contains each item in the list.

      list.get(index)

      Gets the item at index. list.get(index) should be used instead of list[index] if the list's items are going to be updated via list.set(index, value) (as opposed to splice which is the better way).

      var list = new DefineList(["A","B"]);
      list.get(1) //-> "B"
      

      Parameters

      1. index {Number}:

        A numeric position in the list.

      Returns

      {*}:

      The value at index.

      list.get(prop)

      Gets the property at prop if it might not have already been defined.

      var list = new DefineList(["A","B"]);
      list.set("count",1000)
      list.get("count") //-> 1000
      

      Parameters

      1. prop {String}:

        A property on the list.

      Returns

      {*}:

      The value at prop.

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