JsArray Class

An Array exotic object (https://tc39.es/ecma262/#sec-array-exotic-objects): length follows the indices.

public sealed class JsArray : JsObject
Inheritance
JsObject JsArray

Properties

NameDescription
LengthGets the value of the length property.

Gets the value of the length property.

public uint Length { get; }

Property value

uint

Indexers

NameDescription
this[uint]Gets or sets an element of the array, as array[index] does: the getter is [[Get]] (a hole, or an index beyond the length, reads the prototype chain: usually undefined) and the setter is [[Set]] in strict mode (it can extend the array). Both run the accessors and the proxies they meet, so they are used in a scope of the engine (JsEngine.Enter).

this[uint]

JsArray.cs

Gets or sets an element of the array, as array[index] does: the getter is [[Get]] (a hole, or an index beyond the length, reads the prototype chain: usually undefined) and the setter is [[Set]] in strict mode (it can extend the array). Both run the accessors and the proxies they meet, so they are used in a scope of the engine (JsEngine.Enter).

public JsValue this[uint index] { get; set; }

Parameters

index uint
The index: from 0 to 4,294,967,294 (2³² - 2), the largest array index.

Property value

JsValue

Exceptions

ArgumentOutOfRangeException
index is not an array index.
JsException
The element cannot be assigned (a TypeError: e.g. a frozen array), or an accessor threw an exception.
InvalidOperationException
No engine is entered on the thread, or the array or the value belongs to another engine.

Methods

NameDescription
ToArray()Copies the elements of the array (CreateListFromArrayLike): the length is read once, then each element is read as the indexer does. The holes are read from the prototype chain (usually undefined), and the accessors run, so a change of the array during the copy (e.g. by a getter) is visible to the next elements, but not to the length.

ToArray()

JsArray.cs

Copies the elements of the array (CreateListFromArrayLike): the length is read once, then each element is read as the indexer does. The holes are read from the prototype chain (usually undefined), and the accessors run, so a change of the array during the copy (e.g. by a getter) is visible to the next elements, but not to the length.

public JsValue[] ToArray()

Returns

JsValue[]

Exceptions

InvalidOperationException
No engine is entered on the thread, the array belongs to another engine, or its length is larger than Array.MaxLength.