Int8Array
Creates a new Int8Array typed array representing an array of 8-bit signed integers (range -128 to 127)
Syntax
new Int8Array(length) or new Int8Array(buffer, byteOffset?, length?)Parameters
| Parameter | Type | Description |
|---|---|---|
| length | number | ArrayBuffer | ArrayLike<number> | Array length, buffer, or array-like source |
Return Value
A new Int8Array instance
Examples
const arr = new Int8Array(3)
arr[0] = 127
arr[1] = -128
console.log(arr) // Int8Array [127, -128, 0]const arr = new Int8Array([1, -1, 127, -128])
console.log(arr.length) // 4const arr = new Int8Array(4)
arr[0] = 200 // overflows
console.log(arr[0]) // -56 (wraps around)Understanding Int8Array
The Int8Array method in JavaScript creates a new Int8Array typed array representing an array of 8-bit signed integers (range -128 to 127). 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 Int8Array(length) or new Int8Array(buffer, byteOffset?, length?). It accepts 1 parameter: length. When called, it returns a new int8array instance. Understanding when and how to use Int8Array() helps you write more expressive, readable code.
Common use cases for Int8Array include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like uint8array-constructor, int16array-constructor, int32array-constructor, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Int8Array 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
Uint8ArrayCreates a new Uint8Array typed array representing an array of 8-bit unsigned integers initialized to zero
Int16ArrayCreates a new Int16Array typed array representing an array of 16-bit signed integers (range -32768 to 32767)
Int32ArrayCreates a new Int32Array typed array representing an array of 32-bit signed integers
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.