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:
Slice
sequence<Fruit> FruitPlatter;
We can use the FruitPlatter
sequence as shown below:
JavaScript
const platter = [Fruit.Apple]; platter.push(Fruit.Pear);
TypeScript
const platter:FruitPlatter = [Fruit.Apple]; platter.push(Fruit.Pear);
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.