Int16Array
Creates a new Int16Array typed array representing an array of 16-bit signed integers (range -32768 to 32767)
Syntax
new Int16Array(length) or new Int16Array(buffer, byteOffset?, length?)Parameters
| Parameter | Type | Description |
|---|---|---|
| length | number | ArrayBuffer | ArrayLike<number> | Array length, buffer, or array-like source |
Return Value
A new Int16Array instance
Examples
const arr = new Int16Array([32767, -32768, 0])
console.log(arr) // Int16Array [32767, -32768, 0]const buffer = new ArrayBuffer(6)
const view = new Int16Array(buffer)
view[0] = 1000
view[1] = -1000
console.log(view)const audioSamples = new Int16Array(44100)
for (let i = 0; i < audioSamples.length; i++) {
audioSamples[i] = Math.sin(i * 0.1) * 32767
}Understanding Int16Array
The Int16Array method in JavaScript creates a new Int16Array typed array representing an array of 16-bit signed integers (range -32768 to 32767). It belongs to the TypedArray object and is one of the most widely used methods for working with typedarray values in modern JavaScript and TypeScript applications.
The method signature is new Int16Array(length) or new Int16Array(buffer, byteOffset?, length?). It accepts 1 parameter: length. When called, it returns a new int16array instance. Understanding when and how to use Int16Array() helps you write more expressive, readable code.
Common use cases for Int16Array include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like uint16array-constructor, int32array-constructor, int8array-constructor, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Int16Array is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Uint16ArrayCreates a new Uint16Array typed array representing an array of 16-bit unsigned integers (range 0 to 65535)
Int32ArrayCreates a new Int32Array typed array representing an array of 32-bit signed integers
Int8ArrayCreates a new Int8Array typed array representing an array of 8-bit signed integers (range -128 to 127)
More TypedArray Methods
Other methods in the TypedArray object
Related Tools
More TypedArray Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.