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

      function

      Make a copy of a part of a DefineList.

      • source

      list.slice([start[, end]])

      slice creates a copy of a portion of the DefineList.

      var list = new DefineList(['Alice', 'Bob', 'Charlie', 'Daniel', 'Eve']);
      var newList = list.slice(1, 4);
      newList //-> DefineList['Bob', 'Charlie', 'Daniel']
      

      Parameters

      1. start {Number}:

        The index to start copying from. Defaults to 0.

      2. end {Number}:

        The first index not to include in the copy If end is not supplied, slice will copy until the end of the list.

      Returns

      {can-define/list/list}:

      A new DefineList with the extracted elements.

      Use

      slice is the simplest way to copy a DefineList:

      var list = new DefineList(['Alice', 'Bob', 'Eve']);
      var copy = list.slice();
      
      copy           //-> DefineList['Alice', 'Bob', 'Eve']
      list === copy; //-> false
      

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