AS3.0: Add one or more elements to the begining of an array

Written for: ActionScript 3.0

To add one or more elements to the begining of an array, you will have to use unshift method of Array class.

Below is an example.

var albums:Array = new Array("Natty Dread","Rastaman Vibration","Exodus","Kaya");
albums.unshift("Catch A Fire");

trace(albums); //Catch A Fire,Natty Dread,Rastaman Vibration,Exodus,Kaya
Advertisements
Tagged ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Advertisements