JavaScript Mapping for Sequences

On this page:

Basic JavaScript Mapping for Sequences

A Slice sequence maps to a native JavaScript array.  For JavaScript the compiler does not generate a separate named type but for TypeScript it generate a separate named type defining an array with the same element type as the Slice sequence.

With this mapping you can take advantage of all the inherent functionality offered by JavaScript's array type. For example:

sequence<Fruit> FruitPlatter;

We can use the FruitPlatter sequence as shown below:

const platter = [Fruit.Apple];

const platter:FruitPlatter  = [Fruit.Apple];

JavaScript Mapping for Byte Sequences

As an optimization, occurrences of sequence<byte> map to a Uint8Array type, which is more efficient than native arrays for working with binary data.

See Also