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() | Array | Concatenates one or more items or arrays onto the current array. |
| 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] |
| join() | 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() | 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() | 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() | 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. |
| 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() | 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 an 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 an Array
| name | of object | description |
|---|---|---|
| concat() | Array | Concatenates one or more items or arrays onto the current array. |
| exec() | RegExp | Run the regular expression against a string and return a single match. |
| getFiles() | Folder | Get all files and folders inside this folder. |
| match() | String | Run the supplied regular expression against the string and return an array of the results. |
| 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. |
| splitChannels() | Document | split channels of the document |
Arguments that are an Array
| name | in method | of object | description |
|---|---|---|---|
| args | apply() | Function | An array of items to pass as a |
| blacks | selectiveColor() | [pshop] ArtLayer | |
| blues | selectiveColor() | [pshop] ArtLayer | |
| bounds | crop() | [pshop] Document | array of four numbers |
| characteristics | applyCustomFilter() | [pshop] ArtLayer | |
| curve | applyShear() | [pshop] ArtLayer | |
| curveShape | adjustCurves() | [pshop] ArtLayer | |
| cyans | selectiveColor() | [pshop] ArtLayer | |
| flareCenter | applyLensFlare() | [pshop] ArtLayer | |
| greens | selectiveColor() | [pshop] ArtLayer | |
| highlights | adjustColorBalance() | [pshop] ArtLayer | |
| magentas | selectiveColor() | [pshop] ArtLayer | |
| midtones | adjustColorBalance() | [pshop] ArtLayer | |
| neutrals | selectiveColor() | [pshop] ArtLayer | |
| reds | selectiveColor() | [pshop] ArtLayer | |
| region | select() | [pshop] Selection | An Array of points. |
| shadows | adjustColorBalance() | [pshop] ArtLayer | |
| whites | selectiveColor() | [pshop] ArtLayer | |
| yellows | selectiveColor() | [pshop] ArtLayer |