Array in ECMAScript 262

A sparse array.

Inherits from:

Instance Properties

name type description
prototype Object The prototype for a class. [from Object]
constructor Object A reference to the constructor class for the current object instance. [from Object]
length Number The number of items in the array.

Instance Methods

name returns description
toLocaleString() String For most objects, the same as toString() unless explicitly overridden. [from Object]
valueOf() String Returns the internal this value of the object. [from Object]
hasOwnProperty() Boolean Determines if the object/instance itself has the named property or method. [from Object]
isPrototypeOf() Boolean Determines if the calling object prototype is in the inheritance chain for the supplied argument. [from Object]
propertyIsEnumerable() Boolean Determines if the object/instance itself has a property or method of the supplied name which will appear in a for (prop in obj) enumeration. [from Object]
concat() Array Concatenates one or more items or arrays onto the current array.
join() String Returns a string representation of the array, separated by the delimiter of your choice.
reverse() Array Reverses the order of the elements in the array, and returns the array.
slice() Array Return a specified section of an array.
shift() Object Removes the first element of the array and returns it.
sort() Array Sort the array.
splice() Array Remove a section from the array and return it; optionally inserting new values in that place.
toString() String Returns a string representation of the object. [from Object]
pop() Object Remove the last element from the array and return it.
push() Number Adds one or more elements to the end of the array, returning the new length.
unshift() Number Insert items to the front of an array, and return the new length.

Description

Arrays in ECMAScript are sparse—they are not contiguous blocks of memory. This means that var foo = new Array(100000000); is valid, and will not crash your computer allocating gobs of memory.

Arrays auto-grow. Attempting to access an index greater than the length of the array simply returns undefined, not an error. Setting a value for an index greater than the length property causes the length to be one greater than the index set.

var foo = new Array(10);
if (foo.length==10){ //true }
foo[20]=3;
if (foo.length==21){ //true }

Arrays may be initialized either using the var foo = new Array(arraySize); constructor, or using the array literal notation, var foo = []; The latter is less bytes, and also faster. Additionally, it is possible to specify initial values of the array using the array literal notation:

var cars = [ 'Mustang' , 'Accord LX' , 'EarthDestroyer 2000' ];
if (cars.length==3){ //true }

The length property is read-write; changing its value to a new, lower value is a quick way to truncate an array, e.g. cars.length=0 empties out the array.

Properties that are a Array

name object description
arguments Function An array of all parameters passed to the function/method.
arguments [pshop] Application (read only)
documents [pshop] Application (read only)
linkedLayers [pshop] ArtLayer (read only) Other Layers linked to this one.
histogram [pshop] Channel (read only) a histogram of values for the channel
componentChannels [pshop] Document (read only) all color component channels for this document
histogram [pshop] Document (read only) a histogram of values for the composite document (only for RGB, CMYK and 'Indexed colors' documents)
keywords [pshop] DocumentInfo list of keywords
supplementalCategories [pshop] DocumentInfo
enabledChannels [pshop] LayerSet channels that are enabled for the layer set
linkedLayers [pshop] LayerSet (read only) array of Layer objects
position [pshop] TextItem array of two numbers; position of origin (unit value)
activeChannels [pshop] Document selected channels for document

Methods that return a Array

name of object description
concat() Array Concatenates one or more items or arrays onto the current array.
reverse() Array Reverses the order of the elements in the array, and returns the array.
slice() Array Return a specified section of an array.
sort() Array Sort the array.
splice() Array Remove a section from the array and return it; optionally inserting new values in that place.
split() String Separate the string into pieces and return an array of the resulting substrings.
getFiles() Folder Get all files and folders inside this folder.
splitChannels() Document split channels of the document
match() String Run the supplied regular expression against the string and return an array of the results.
exec() RegExp Run the regular expression against a string and return a single match.

Arguments that are a Array

name in method of object description
args apply() Function An array of items to pass as a
shadows adjustColorBalance() [pshop] ArtLayer
midtones adjustColorBalance() [pshop] ArtLayer
highlights adjustColorBalance() [pshop] ArtLayer
curveShape adjustCurves() [pshop] ArtLayer
characteristics applyCustomFilter() [pshop] ArtLayer
flareCenter applyLensFlare() [pshop] ArtLayer
curve applyShear() [pshop] ArtLayer
reds selectiveColor() [pshop] ArtLayer
yellows selectiveColor() [pshop] ArtLayer
greens selectiveColor() [pshop] ArtLayer
cyans selectiveColor() [pshop] ArtLayer
blues selectiveColor() [pshop] ArtLayer
magentas selectiveColor() [pshop] ArtLayer
whites selectiveColor() [pshop] ArtLayer
neutrals selectiveColor() [pshop] ArtLayer
blacks selectiveColor() [pshop] ArtLayer
bounds crop() [pshop] Document array of four numbers
region select() [pshop] Selection An Array of points.