-
Notifications
You must be signed in to change notification settings - Fork 0
API Int16Array
Fixed-length packed array of signed 16-bit integers.
Int16Array is a primitive-backed array for compact signed short data such as audio samples, coordinate deltas, and mid-range counters. Elements live in contiguous native storage, so the array avoids the per-element object allocation of a general Array.
The length is fixed at construction. push, pop, and element deletion are unavailable; elements are read and written through numeric indexes.
var samples = new Int16Array(2);
samples[0] = -1024;
return samples[0]; // -1024Warning
Indexing outside 0 to length - 1 raises a runtime error. Validate computed indexes before reading or writing.
Use Int32Array when the range of a signed 16-bit integer is too small, or Array when the element type must vary or the collection has to grow.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
length |
number |
No | Non-negative element count. Omitting it creates an empty array. |
Returns
Int16Array — a fixed-length array whose elements start at 0.
Example
var deltas = new Int16Array(4);
return deltas[3]; // 0Returns
number — the fixed element count.
Behavior
Read-only. The value never changes for a given instance.
Example
return new Int16Array(8).length; // 8Parameters
| Name | Type | Required | Description |
|---|---|---|---|
value |
number |
No | Value written to every element. Defaults to 0. |
Returns
Int16Array — this array, so calls can be chained.
Behavior
The value is converted to a signed 16-bit integer before it is stored, and every element is overwritten in place.
Example
var samples = new Int16Array(3);
samples.fill(-5);
return samples[2]; // -5AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License