DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • prototype
    • concat
    • forEach
    • indexOf
    • join
    • pop
    • push
    • replace
    • reverse
    • shift
    • slice
    • splice
    • unshift
  • static
    • can.List.Map
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • can.List
  • /
  • shift
  • / On this page
    • shift

      function

      Remove en element from the front of a list.

      • source

      list.shift()

      shift removes an element from the beginning of a List.

      Returns

      {*}:

      the element just shifted off the List, or undefined if the List is empty

      shift is the opposite action from unshift:

      var list = new can.List(['Alice']);
      
      list.unshift('Bob', 'Eve');
      list.attr(); // ['Bob', 'Eve', 'Alice']
      
      list.shift(); // 'Bob'
      list.shift(); // 'Eve'
      list.shift(); // 'Alice'
      list.shift(); // undefined
      

      Events

      pop causes change, remove, and length events to be fired if the List is not empty when it is called.

      See also

      shift has a counterpart in unshift, or you may be looking for push and its counterpart pop.

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