The Int8Array array 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 creates 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 map function and value used for map function if needed.
Int8Array.from(source[, mapFn[, thisArg]])
parameters: This method accepts three parameters that are specified below-
- source: This parameter is an array-like or iterable object which is used to convert to a Int8Array object.
- mapFn: This parameter is Optional which is Map function to call on every element of the Int8Array array.
- thisArg: This parameter is Optional which is value to use as this when executing mapFn.
Return Value: this method returns a new Int8Array instance.
8, 7, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9
10, 3, 2, 5, 4