Adobe FrameMaker-12 Object Model JS: Array

FrameMaker 12.0

Class

Array

  An array with integer indexing and a length property.

QuickLinks

Array, concat, join, pop, push, reverse, shift, slice, sort, splice, toLocaleString, toSource, toString, unshift

Properties

PropertyTypeAccessDescription
lengthnumber r/wThe length of the array

Methods

Constructor

Array Array (length: number[, element: any])
Creates and returns a new array.
Takes any number of parameters, which become the elements of the array, or a single value which becomes the length of an empty array. Note that you cannot create a one-element array, as the single parameter value is interpreted as the length. Returns the new array.

ParameterTypeDescription
lengthnumberIf no other parameters are passed, the initial length of the empty array.
Otherwise, the first element.
element any If there is more than one parameter, the array is initialized with the given parameters. (Optional)

Example new Array()
new Array (length)
new Array (11, 22, 33, 44)

Instances

Array concat (value: any)
Returns a new array created by concatenating the given values to the end of the original array.
The original array is unchanged. If an array is provided as a parameter to concat(), each of its elements are appended as separate array elements at the end of the new array. Returns a new array, the result of concatenation the given values to the end of the original array.

ParameterTypeDescription
value any Any number of values to be added to the end of the array.
Can also be arrays.

Examplearray.concat(value1,...valueN)

string join ([delimiter: string])
Joins all elements of the array into a string; optionally, each element is separated by delimiter.
Returns the string containing the joined elements and delimiters.

ParameterTypeDescription
delimiterstringA string used to separate each element of the array.
If omitted, the array elements are separated with a comma. (Optional)

Examplearray.join(delimiter)

any pop ()
Removes the last element from the array, decreases the length by 1, and returns the value of the element.
Returns the value of the deleted array element.

Examplearray.pop()

number push (value: number)
Places one or more values onto the end of the array and increases length by n.
Returns the new length of the array.

ParameterTypeDescription
valuenumberAny number of values to be pushed onto the end of the array.

Examplearray.push(value1,...valueN)

Array reverse ()
Reverses the order of the elements in the array.
Returns the reversed array.

Examplearray.reverse()

any shift ()
Removes the first element from the array, decreases the length by 1, and returns the value of the element.
Returns the value of the deleted array element.

Examplearray.shift()

Array slice ()
Creates a new array, which contains a subset of the original array's elements.
The slice begins with the index start, and continues up to, but not including the index, end. If start or end is a negative number, the indexed is resolved counting backwards from the end of the array resulting in the element array[array. length + negativeIndex]. Returns a new array containing elements array[start] through array[end-1].

Examplearray.slice(start, end)

void sort (userFunction: Function)
Sorts the elements of the array in place, using the given function to compare to elements.
If no function is provided, the elements are sorted alphabetically. Returns no return value.

ParameterTypeDescription
userFunctionFunctionA user-supplied function of the form userFunction(a, b) which returns less than 0 if a is greater than b, 0 if a and b are equal, and greater than 0 if b is greater than a.

Examplearray.sort(userFunction)

Array splice (start: number[, num: number][, value: any])
Removes num elements from the array beginning with index, start.
Optionally insert new elements beginning at index start. To ensure contiguity, elements are moved up to fill in any gaps. Returns a new array containing any elements deleted from the original array.

ParameterTypeDescription
startnumberThe index of the first element to remove. Negative values are relative to the end of the array.
numnumberThe number of array elements to remove, including start. If omitted, all elements from array index start to the end of the array are removed.
(Optional)
value any A list of one or more values to be added to the array starting at index start.
Must specify a value for num, to use this argument. (Optional)

Examplearray.splice(start, num, value1, ...valuen)

string toLocaleString ()
Converts an array to a string and returns the string (localized).

string toSource ()
Creates a string representation of this object that can be fed back to eval() to re-create an object. Works only with built-in classes.

string toString ()
Converts an array to a string and returns the string.
Yields the same result as array. join() when called without a parameter. Returns a comma-separated list of all the elements of the array.

Examplearray.toString()

number unshift (value: any)
Adds one or more elements to the beginning of the array.
Returns the new array length.

ParameterTypeDescription
value any The values of one or more elements to be added to the beginning of the array.

Examplearray.unshift(value1,...valuen)

Element of

ListItem.subItems

Used in:

any Function.apply (thisObj: Object, args: Array)

Return

Array Array.Array (length: number[, element: any])

Array Array.concat (value: any)

Array Array.reverse ()

Array Array.slice ()

Array Array.splice (start: number[, num: number][, value: any])

Array Folder.getFiles (mask: any)

Array RegExp.exec (text: string)

Array String.match (regexp: RegExp)

Array XML.inScopeNamespaces ()

Array XML.namespaceDeclarations ()

Jongware, 18-Jan-2015 v1.0Contents :: Index