Arrays can call unshift() to add any number of elements to the front of the array just like push(). : unshift « Array « Flash / Flex / ActionScript






Arrays can call unshift() to add any number of elements to the front of the array just like push().

 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var queue:Array = new Array();
        queue.push("A");
        queue.push("J");
        queue.push("W");
        queue.unshift("J", "D");
        trace(queue); // Displays: Jim,Doro,James,Will
    }
  }
}

        








Related examples in the same category

1.Prepending Elements to the Beginning of an Array: the unshift() method
2.unshift( )method adds one or more elements to the beginning of the array: theArray.unshift(item1, item2,...itemn);