concat( ) does not flatten nested arrays : concat « Array « Flash / Flex / ActionScript






concat( ) does not flatten nested arrays

 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var x:Array = [1, 2, 3];
        var y:Array = [[5, 6], [7, 8]];
        var z:Array = x.concat(y);  // Result is [1, 2, 3, [5, 6], [7, 8]].
        
        trace(z); //1,2,3,5,6,7,8

    }
  }
}

        








Related examples in the same category

1.The concat( ) method combines two or more arrays into a single, new array: origArray.concat(elementList)
2.Use concat to combine two arrays
3.Creating New Arrays from Existing Arrays