Revision: 24988
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 17, 2010 11:09 by adrianparr
Initial Code
var myArray:Array = new Array(); // PUSH // Adds one or more elements to the end of an array and returns the new length of the array. myArray = ["a","b","c","d"]; trace(myArray); myArray.push("e"); trace(myArray); // OUTPUT // a,b,c,d // a,b,c,d,e // POP // Removes the last element from an array and returns the value of that element. myArray = ["a","b","c","d"]; trace(myArray); myArray.pop(); trace(myArray); // OUTPUT // a,b,c,d // a,b,c // UNSHIFT // Adds one or more elements to the beginning of an array and returns the new // length of the array. The other elements in the array are moved from their // original position, i, to i+1. myArray = ["a","b","c","d"]; trace(myArray); myArray.unshift("_"); trace(myArray); // OUTPUT // a,b,c,d // _,a,b,c,d // SHIFT // Removes the first element from an array and returns that element. // The remaining array elements are moved from their original position, i, to i-1. myArray = ["a","b","c","d"]; trace(myArray); myArray.shift(); trace(myArray); // OUTPUT // a,b,c,d // b,c,d
Initial URL
Initial Description
I always forget which method does what. This is just as a quick reminder.
Initial Title
AS3 Using Push, Pop, Unshift and Shift on Arrays
Initial Tags
array
Initial Language
ActionScript 3