TopLevel
Class Array
Array
An Array of items.
Properties
length
:
Number
The length of the Array.
Constructor Summary
Array()
Constructs an Array.
Method Summary
copyWithin(target
:
Number, start
:
Number, end
:
Number)
:
Array
Copies elements within this array.
entries()
:
ES6Iterator
Returns an iterator containing all index/value pairs of this array.
every(callback
:
Function)
:
boolean
Returns true if every element in this array satisfies the test performed in the callback function.
every(callback
:
Function, thisObject
:
Object)
:
boolean
Returns true if every element in the thisObject argument satisfies the test performed in the callback function, false otherwise.
fill(value
:
Object, start
:
Number, end
:
Number)
:
Array
Sets multiple entries of this array to specific value.
filter(callback
:
Function)
:
Array
Returns a new Array with all of the elements that pass the test implemented by the callback function.
filter(callback
:
Function, thisObject
:
Object)
:
Array
Returns a new Array with all of the elements that pass the test implemented by the callback function that is run against the specified Array, thisObject.
find(callback
:
Function, thisObject
:
Object)
:
Object
Returns the first value within the array that satisfies the test defined in the callback function.
findIndex(callback
:
Function, thisObject
:
Object)
:
Number
Returns the index of the first value within the array that satisfies the test defined in the callback function.
forEach(callback
:
Function)
:
void
Runs the provided callback function once for each element present in the Array.
forEach(callback
:
Function, thisObject
:
Object)
:
void
Runs the provided callback function once for each element present in the specified Array, thisObject.
static from(arrayLike
:
Object, mapFn
:
Function, thisObject
:
Object)
:
Array
Creates a new array from an array-like object or an Iterable.
includes(valueToFind
:
Object, fromIndex
:
Number)
:
boolean
Returns if the array contains a specific value.
indexOf(elementToLocate
:
Object)
:
Number
Returns the first index at which a given element can be found in the array, or -1 if it is not present.
indexOf(elementToLocate
:
Object, fromIndex
:
Number)
:
Number
Returns the first index at which a given element can be found in the array starting at fromIndex, or -1 if it is not present.
keys()
:
ES6Iterator
Returns an iterator containing all indexes of this array.
lastIndexOf(elementToLocate
:
Object)
:
Number
Returns the last index at which a given element can be found in the array, or -1 if it is not present.
lastIndexOf(elementToLocate
:
Object, fromIndex
:
Number)
:
Number
Returns the last index at which a given element can be found in the array starting at fromIndex, or -1 if it is not present.
map(callback
:
Function)
:
Array
Creates a new Array with the results of calling the specified function on every element in this Array.
map(callback
:
Function, thisObject
:
Object)
:
Array
Creates a new Array with the results of calling the specified function on every element in the specified Array.
reverse()
:
void
Reverses the order of the elements in the Array.
slice(start
:
Number, end
:
Number)
:
Array
Returns a new Array containing a portion of the Array using the specified start and end positions.
some(callback
:
Function)
:
boolean
Returns true if any of the elements in the Array pass the test defined in the callback function, false otherwise.
some(callback
:
Function, thisObject
:
Object)
:
boolean
Returns true if any of the elements in the specified Array pass the test defined in the callback function, false otherwise.
sort(function
:
Function)
:
Array
Sorts the elements of the Array in alphabetical order based on character encoding.
splice(start
:
Number, deleteCount
:
Number, values
:
Object...)
:
Array
Deletes the specified number of elements from the Array at the specified position, and then inserts values into the Array at that location.
toLocaleString()
:
String
Converts the Array to a localized String.
values()
:
ES6Iterator
Returns an iterator containing all values of this array.
Methods inherited from class
Object
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
Constructor Detail
Array
public Array(length
:
Number)
Constructs an Array of the specified
length.
Parameters:
length
-
the length of the Array.
Array
public Array(values
:
Object...)
Constructs an Array using the specified values.
Parameters:
values
-
zero or more values that are stored in the Array.
Method Detail
concat
Constructs an Array by concatenating multiple values.
Parameters:
values
-
one or more Array values.
Returns:
a new Array containing the concatenated values.
copyWithin
Copies elements within this array. The array length is not changed.
API Versioned:
From version 21.2.
Parameters:
target
-
The target of the first element to copy.
start
-
Optional. The first index to copy. Default is 0.
end
-
Optional. The index of the end. This element is not included. Default is copy all to the array end.
Returns:
This array.
entries
entries()
:
ES6Iterator
Returns an iterator containing all index/value pairs of this array.
The iterator produces a series of two-element arrays with the first element as the index and the second element as the value.
API Versioned:
From version 21.2.
every
every(callback
:
Function)
:
boolean
Returns true if every element in this array satisfies the test
performed in the callback function. The callback function is
invoked with three arguments: the value of the element,
the index of the element, and the Array object being traversed.
Parameters:
callback
-
the function to call to determine if every element in this array satisfies the test defined by the function. The callback function is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
Returns:
true if every element in this array satisfies the test performed in the callback function.
See Also:
every
Returns true if every element in the thisObject argument satisfies the
test performed in the callback function, false otherwise.
The callback function is invoked with three arguments: the value of the
element, the index of the element, and the Array object being traversed.
Parameters:
callback
-
the function to call to determine if every element in this array satisfies the test defined by the function. The callback function is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
thisObject
-
the Object to use as 'this' when executing callback.
Returns:
true if every element in thisObject satisfies the test performed in the callback function, false otherwise.
See Also:
fill
Sets multiple entries of this array to specific value.
API Versioned:
From version 21.2.
Parameters:
value
-
The value to set.
start
-
Optional. The first index to copy. Default is 0.
end
-
Optional. The index of the end. This element is not included. Default is copy all to the array end.
Returns:
This array.
filter
Returns a new Array with all of the elements that pass the test
implemented by the callback function. The callback function is
invoked with three arguments: the value of the element,
the index of the element, and the Array object being traversed.
Parameters:
callback
-
the function that is called on this Array and which returns a new Array containing the elements that satisfy the function's test. The callback function is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
Returns:
a new Array containing the elements that satisfy the function's test.
filter
Returns a new Array with all of the elements that pass the test
implemented by the callback function that is run against the
specified Array, thisObject. The callback function is
invoked with three arguments: the value of the element,
the index of the element, and the Array object being traversed.
Parameters:
callback
-
the function that is called on the thisObject Array and which returns a new Array containing the elements that satisfy the function's test. The callback function is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
thisObject
-
the Object to use as 'this' when executing callback.
Returns:
a new Array containing the elements that satisfy the function's test.
find
Returns the first value within the array that satisfies the test
defined in the callback function.
API Versioned:
From version 21.2.
Parameters:
callback
-
The function to call, which is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
thisObject
-
The object to use as 'this' when executing callback.
Returns:
The first value within the array that satisfies the test defined in the callback function,
undefined
if no matching value was found.
findIndex
Returns the index of the first value within the array that satisfies the test
defined in the callback function.
API Versioned:
From version 21.2.
Parameters:
callback
-
The function to call, which is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
thisObject
-
The object to use as 'this' when executing callback.
Returns:
The index of the first value within the array that satisfies the test defined in the callback function,
-1
if no matching value was found.
forEach
forEach(callback
:
Function)
:
void
Runs the provided callback function once for each element present in
the Array. The callback function is invoked only for indexes of the
Array which have assigned values; it is not invoked for indexes which
have been deleted or which have never been assigned a value.
Parameters:
callback
-
the function to call, which is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
forEach
Runs the provided callback function once for each element present in
the specified Array, thisObject. The callback function is invoked only
for indexes of the Array which have assigned values; it is not invoked
for indexes which have been deleted or which have never been assigned
a value.
Parameters:
callback
-
the function to call, which is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
thisObject
-
the Object to use as 'this' when executing callback.
from
Creates a new array from an array-like object or an Iterable.
API Versioned:
From version 21.2.
Parameters:
arrayLike
-
An array-like object or an iterable that provides the elements for the new array.
mapFn
-
Optional. A function that maps the input elements into the value for the new array.
thisObject
-
Optional. The Object to use as 'this' when executing mapFn.
Returns:
The newly created array.
includes
Returns if the array contains a specific value.
API Versioned:
From version 21.2.
Parameters:
valueToFind
-
The value to look for.
fromIndex
-
Optional. The index to start from.
Returns:
true
if the value is found in the array else false
.
indexOf
Returns the first index at which a given element can be found in the
array, or -1 if it is not present.
Parameters:
elementToLocate
-
the element to locate in the Array.
Returns:
the index of the element or -1 if it is no preset.
indexOf
Returns the first index at which a given element can be found in the
array starting at fromIndex, or -1 if it is not present.
Parameters:
elementToLocate
-
the element to locate in the Array.
fromIndex
-
the index from which to start looking for the element.
Returns:
the index of the element or -1 if it is no preset.
isArray
static isArray(object
:
Object)
:
boolean
Checks if the passed object is an array.
Parameters:
object
-
The object to ckeck.
Returns:
true
if the passed object is an array else false
.
join
join()
:
String
Converts all Array elements to Strings and concatenates them.
Returns:
a concatenated list of all Array elements as a String.
join
Converts all array elements to Strings and concatenates them.
Parameters:
separator
-
an optional character or string used to separate one element of the Array from the next element in the return String.
Returns:
a concatenated list of all Array elements as a String where the specified delimiter is used to separate elements.
keys
keys()
:
ES6Iterator
Returns an iterator containing all indexes of this array.
API Versioned:
From version 21.2.
lastIndexOf
Returns the last index at which a given element can be found in the
array, or -1 if it is not present. The array is searched backwards.
Parameters:
elementToLocate
-
the element to locate in the Array.
Returns:
the index of the element or -1 if it is no preset.
lastIndexOf
Returns the last index at which a given element can be found in the
array starting at fromIndex, or -1 if it is not present.
The array is searched backwards.
Parameters:
elementToLocate
-
the element to locate in the Array.
fromIndex
-
the index from which to start looking for the element. The array is searched backwards.
Returns:
the index of the element or -1 if it is no present.
map
Creates a new Array with the results of calling the specified function
on every element in this Array. The callback function is invoked only
for indexes of the Array which have assigned values; it is not invoked
for indexes which have been deleted or which have never been assigned
values.
Parameters:
callback
-
the function to call, which is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
Returns:
a new Array with the results of calling the specified function on every element in this Array.
map
Creates a new Array with the results of calling the specified function
on every element in the specified Array. The callback function is invoked only
for indexes of the Array which have assigned values; it is not invoked
for indexes which have been deleted or which have never been assigned
values.
Parameters:
callback
-
the function to call, which is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
thisObject
-
the Object to use as 'this' when executing callback.
Returns:
a new Array with the results of calling the specified function on every element in this Array.
of
Creates a new array from a variable list of elements.
API Versioned:
From version 21.2.
Parameters:
values
-
The array values.
Returns:
The newly created array.
pop
pop()
:
Object
Removes and returns the last element of the Array.
Returns:
the last element of the Array.
push
Appends elements to the Array.
Parameters:
values
-
one or more values that will be appended to the Array.
Returns:
the new length of the Array.
shift
shift()
:
Object
Shifts elements down in the Array and returns the
former first element.
Returns:
the former first element.
slice
Returns a new Array containing a portion of the
Array using the specified start and end positions.
Parameters:
start
-
the location in the Array to start the slice operation.
end
-
the location in the Array to stop the slice operation.
Returns:
a new Array containing the members bound by start and end.
some
some(callback
:
Function)
:
boolean
Returns true if any of the elements in the Array pass the test
defined in the callback function, false otherwise.
Parameters:
callback
-
the function to call, which is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
Returns:
true if any of the elements in the Array pass the test defined in the callback function, false otherwise.
some
Returns true if any of the elements in the specified Array pass the test
defined in the callback function, false otherwise.
Parameters:
callback
-
the function to call, which is invoked with three arguments: the value of the element, the index of the element, and the Array object being traversed.
thisObject
-
the Object to use as 'this' when executing callback.
Returns:
true if any of the elements in the Array pass the test defined in the callback function, false otherwise.
sort
sort()
:
Array
Sorts the elements of the Array in alphabetical order based on character encoding.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
Returns:
a reference to the Array.
sort
Sorts the elements of the Array in alphabetical
order based on character encoding.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
Parameters:
function
-
a Function used to specify the sorting order.
Returns:
a reference to the Array.
See Also:
splice
Deletes the specified number of elements from the Array at the specified position,
and then inserts values into the Array at that location.
Parameters:
start
-
the start location.
deleteCount
-
the number of items to delete.
values
-
zero or more values to be inserted into the Array.
toLocaleString
toLocaleString()
:
String
Converts the Array to a localized String.
Returns:
a localized String representing the Array.
toString
toString()
:
String
Converts the Array to a String.
Returns:
a String representation of the Array.
unshift
Inserts elements at the beginning of the Array.
Parameters:
values
-
one or more vales that will be inserted into the beginning of the Array.
Returns:
the new length of the Array.
values
values()
:
ES6Iterator
Returns an iterator containing all values of this array.
API Versioned:
From version 21.2.
© Copyright 2000-2024, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners.