Using the forEach() Method to loop through items in an array : forEach « Array « Flash / Flex / ActionScript






Using the forEach() Method to loop through items in an array

 

function functionName(element:*, index:int, array:Array):void
package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var subjects:Array = ["Art", "Science", "Math", "History"];
        subjects.forEach(traceArray);

    }


    function traceArray(element:*, index:int, a:Array):void {
        trace("["+ index + "] = "+ element);
    }
  }
}

        








Related examples in the same category