JavaScript Mapping for Sequences
On this page:
Basic JavaScript Mapping for Sequences
A Slice sequence maps to a native JavaScript array. This means that the Slice-to-JavaScript compiler does not generate a separate named type for a Slice sequence. It also means that 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
var platter = [Fruit.Apple]; platter.push(Fruit.Pear);
JavaScript Mapping for Byte Sequences
As an optimization, occurrences of sequence<byte>
map to a native buffer type, which is more efficient than native arrays for working with binary data. For browser applications, sequence<byte>
maps to Uint8Array
, and for Node.js applications it maps to the native Buffer
type.