/ Published in: ActionScript 3

I always forget which method does what. This is just as a quick reminder.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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
Comments
