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

      function

      Sets an item or property or items or properties on a list.

      • source

      list.set(prop, value)

      Sets the property at prop. This should be used when the property isn't already defined.

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

      Parameters

      1. prop {Number}:

        A property name.

      2. value {*}:

        The value to add to the list.

      Returns

      {can-define/list/list}:

      The list instance.

      list.set(newProps)

      Updates the properties on the list with newProps.

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

      Parameters

      1. newProps {Object}:

        An object of properties and values to set on the list.

      Returns

      {can-define/list/list}:

      The list instance.

      list.set(index, value)

      Sets the item at index. Typically, splice should be used instead.

      var list = new DefineList(["A","B"]);
      list.set(2,"C");
      

      Parameters

      1. index {Number}:

        A numeric position in the list.

      2. value {*}:

        The value to add to the list.

      Returns

      {can-define/list/list}:

      The list instance.

      list.set(newItems [,replaceAll])

      Replaces items in the list with newItems

      var list = new DefineList(["A","B"]);
      list.set(["c"])        //-> DefineList["c","B"]
      list.set(["x"], true)  //-> DefineList["x"]
      

      Parameters

      1. newItems {Array}:

        Items used to replace existing items in the list.

      2. replaceAll {Boolean}:

        If true, will remove items at the end of the list.

      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.