Last Updated : 12 Jul, 2025
The Javascript Int8Array represents an array of twos-complement of 8-bit signed integers. By default, the contents of Int8Array are initialized to 0. from the () function of Int8Array used to create a new Int8Array from an array-like or iterable object. So when you want to convert an arrayLike or iterable object to Int8Array then you can use this function by passing the object as a parameter to this function along with the map function and value used for the map function if needed.
Syntax:
Int8Array.from(source[, mapFn[, thisArg]])
Parameters: This method accepts three parameters that are specified below-
Return Value: This method returns a new Int8Array instance.
JavaScript examples to Illustrate the working of from() function:
Example 1: In this example, we will see the use of JavaScript Int8Array from() Method.
javascript
//create a Int8Array from a string like structure
let array = Int8Array.from('876543456789');
//print the result
console.log(array);
Output:
8, 7, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9
Example 2: In this example, we will add one to every element of the array using the JavaScript Int8Array from() Method.
javascript
//create a Int8Array from a array by
//adding 1 to each number using function
let array = Int8Array.from([9, 2, 1, 4, 3], z => z + 1);
//print the result
console.log(array);
Output:
10, 3, 2, 5, 4
We have a complete list of Javascript Array methods, to check those please go through this Javascript Array Complete reference article.
Supported Browsers: The browsers supported by JavaScript Array isArray() method are listed below:
We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4