List

API reference for the List type.

A list of items that can be read and updated.

Type Parameters

S

M

Methods

countfunction
Required

Gets the number of items in the list.

Returns

The number of items.

number

toArrayfunction
Required

Converts the list to an array.

Returns

An array containing all items. The items are the same as in the list.

readonly M[]

forEachfunction
Required

Executes a function for each item in the list.

Parameters

callbackForEachCallback<M>
Required

The function to run for each item.

Parameters

itemM
Required

The current item in the list.

indexnumber
Required

The index of the current item.

Returns

void

Returns

void

filterfunction
Required

Creates a new array with items that pass a test.

Parameters

filterFilterPredicate<M>
Required

A function that tests each item. Returns true to keep the item.

Parameters

itemM
Required

The item to test.

Returns

true if the item should be included, otherwise false.

boolean

Returns

An array of items that passed the test.

readonly M[]

insertBeforefunction
Required

Adds a copy of an item to the list and places it right before another item.

Parameters

refundefined | M
Required

The existing item to place the new item before. If ref is undefined, the new item is added at the end of the list. If ref does not exist in the list, the operation fails.

itemS
Required

The item to add. A copy of this item will be inserted.

Returns

The added item, or undefined if the operation failed.

undefined | M

insertAfterfunction
Required

Adds a copy of an item to the list and places it right after another item.

Parameters

refundefined | M
Required

The existing item to place the new item after. If ref is undefined, the new item is added at the end of the list. If ref does not exist in the list, the operation fails.

itemS
Required

The item to add. A copy of this item will be inserted.

Returns

The added item, or undefined if the operation failed.

undefined | M

moveBeforefunction
Required

Moves an existing item to a new position right before another item.

Parameters

refundefined | M
Required

The existing item to move the item before. If ref is undefined, the item is moved to the end of the list. If ref does not exist in the list, the operation fails.

itemM
Required

The item to move. The operation fails if the item is not already in the list.

Returns

void

moveAfterfunction
Required

Moves an existing item to a new position right after another item.

Parameters

refundefined | M
Required

The existing item to move the item after. If ref is undefined, the item is moved to the end of the list. If ref does not exist in the list, the operation fails.

itemM
Required

The item to move. The operation fails if the item is not already in the list.

Returns

void

deletefunction
Required

Removes an item from the list.

Parameters

itemM
Required

The item to remove from the list.

Returns

void