Array in ECMAScript 262

A sparse array.

Inherits from:

Instance Properties

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

Instance Methods

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

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
activeChannels [pshop] Document selected channels for document
arguments [pshop] Application (read only)
arguments Function An array of all parameters passed to the function/method.
componentChannels [pshop] Document (read only) all color component channels for this document
documents [pshop] Application (read only)
enabledChannels [pshop] LayerSet channels that are enabled for the layer set
histogram [pshop] Channel (read only) a histogram of values for the channel
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
linkedLayers [pshop] ArtLayer (read only) Other Layers linked to this one.
linkedLayers [pshop] LayerSet (read only) array of Layer objects
position [pshop] TextItem array of two numbers; position of origin (unit value)
supplementalCategories [pshop] DocumentInfo

Methods that return a Array

name of object description
concat([item1],[item2],[...]) Array Concatenates one or more items or arrays onto the current array.
data() Selection Get the data array for the first group in the selection.
exec(sourceString) RegExp Run the regular expression against a string and return a single match.
getFiles([mask]) Folder Get all files and folders inside this folder.
match(expr) String Run the supplied regular expression against the string and return an array of the results.
mouse(container) d3 Find x,y coordinates of the current mouse event relative to a container element.
reverse() Array Reverses the order of the elements in the array, and returns the array.
slice(start,[end]) Array Return a specified section of an array.
sort([compareFunction]) Array Sort the array.
splice(start,deleteCount,[newItem1],…) Array Remove a section from the array and return it; optionally inserting new values in that place.
split([separator],[limit]) String Separate the string into pieces and return an array of the resulting substrings.
splitChannels() Document split channels of the document
touches(container) d3 Find multiple x,y coordinates of the current touch events relative to a container element.

Arguments that are a Array

name in method of object description
args apply([thisScope],[args]) Function An array of items to pass as a
blacks selectiveColor(selectionMethod,[reds],[yellows],…) [pshop] ArtLayer
blues selectiveColor(selectionMethod,[reds],[yellows],…) [pshop] ArtLayer
bounds crop(bounds,[angle],[width],…) [pshop] Document array of four numbers
characteristics applyCustomFilter(characteristics,scale,offset) [pshop] ArtLayer
curve applyShear(curve,undefinedAreas) [pshop] ArtLayer
curveShape adjustCurves(curveShape) [pshop] ArtLayer
cyans selectiveColor(selectionMethod,[reds],[yellows],…) [pshop] ArtLayer
dataValues data(dataValues,[keyCalculator]) [d3] Selection
flareCenter applyLensFlare(brightness,flareCenter,lensType) [pshop] ArtLayer
greens selectiveColor(selectionMethod,[reds],[yellows],…) [pshop] ArtLayer
highlights adjustColorBalance([shadows],[midtones],[highlights],…) [pshop] ArtLayer
magentas selectiveColor(selectionMethod,[reds],[yellows],…) [pshop] ArtLayer
midtones adjustColorBalance([shadows],[midtones],[highlights],…) [pshop] ArtLayer
neutrals selectiveColor(selectionMethod,[reds],[yellows],…) [pshop] ArtLayer
node select(node) [d3] d3
nodes selectAll(nodes) [d3] d3 May be an array or array-like object (e.g. a NodeList or arguments).
reds selectiveColor(selectionMethod,[reds],[yellows],…) [pshop] ArtLayer
region select(region,[type],[feather],…) [pshop] Selection An Array of points.
shadows adjustColorBalance([shadows],[midtones],[highlights],…) [pshop] ArtLayer
whites selectiveColor(selectionMethod,[reds],[yellows],…) [pshop] ArtLayer
yellows selectiveColor(selectionMethod,[reds],[yellows],…) [pshop] ArtLayer