JavaScript TypedArray.of() Method Last Updated : 10 Jan, 2023 Comments Improve Suggest changes Like Article Like Report The TypedArray.of() method is used to create a new array from a variable number of arguments that are passed to it. Syntax: TypedArray.of( el0, el1, el2, ...elN ) Parameters: This method accepts a variable number of elements, which are used to create the Int16Array array. TypedArray can contain any of the below-mentioned values: Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array BigInt64Array BigUint64Array Return Value: This method returns a new TypedArray instance. The below example illustrates the TypedArray.of() Method in JavaScript: Example 1: In this example, the values passed are the character values that are converted to Int16 by the method. JavaScript <script> // Create a Uint16Array by using // the Int16Array.of() method let int16Arr = new Int16Array; int16Arr = Int16Array.of('31', '52', '16', '80', '24'); // Print the result console.log(int16Arr); </script> Output: [31, 52, 16, 80, 24] Example 2: In this example, the values passed are the Integer values which are converted to Int16 by the method. The value -499999 is converted to 15537. JavaScript <script> // Create a Uint16Array by using // the Int16Array.of() method let int16Arr = new Int16Array; // Accepts the Int16 values int16Arr = Int16Array.of(-49999, 5, 7, 799, 8); // Print the result console.log(int16Arr); </script> Output: [15537, 5, 7, 799, 8] Example 3: In this example, the values passed are the character values that are converted to Uint16 by the method. JavaScript <script> // Create a Uint16Array by using // the Uint16Array.of() method let uint16Arr = new Uint16Array; uint16Arr = Uint16Array.of('31', '50', '26', '60', '24'); // Print the result console.log(uint16Arr); </script> Output: [31, 50, 26, 60, 24] Example 4:In this example, the values passed are the Integer values which are converted to Uint16 by the method. The value -499999 is thus converted to 24289. JavaScript <script> // Create a Uint16Array by using // the Uint16Array.of() method let uint16Arr = new Uint16Array; // Accepts only the Uint16 values uint16Arr = Uint16Array.of(-499999, 5, 7, 799, 8); // Print the result console.log(uint16Arr); </script> Output: [24289, 5, 7, 799, 8] Supported Browsers: ChromeEdgeFirefoxOperaSafari Comment More infoAdvertise with us Next Article JavaScript TypedArray.of() Method P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Methods Similar Reads JavaScript typedArray.of() Method The typedArray.of() is an inbuilt function in JavaScript which is used to construct a new typedArray with a variable number of parameters. Syntax: TypedArray.of(element0, element1, ......) Parameters: It accepts parameters of different elements whose typedArray is going to be created. Return value: 1 min read JavaScript typedArray.set() Method The typedArray.set() is an inbuilt function in JavaScript which is used to stores a number of values in the given typedArray. typedArray.set(typedArray, offset) Parameters: It accept two parameters which are specified below- typedarray: It is the source array. offset: It is optional and it is into t 1 min read JavaScript typedArray.map() Method The typedArray.map() is an inbuilt function in JavaScript which is used to create a new typedArray with the result of a provided function on each element of the given typedArray. Syntax: typedArray.map(callback) Parameters: It accepts a parameter callback function which accept some parameter which a 1 min read JavaScript typedArray.keys() Method The typedArray.keys() is an inbuilt function in JavaScript which is used to return a new array iterator containing the keys for each index of the elements of the given typedArray. Syntax: typedArray.keys() Parameter: This function does not accept anything as parameter. Return value: It returns a new 1 min read JavaScript typedArray.length() Method The typedArray.length is an inbuilt property in JavaScript which is used to return the length of the given typedArray. Syntax: typedArray.length Parameters: It does not accept any parameter because it is a property not a function. Return value: It returns the length of the given typedArray. Example 2 min read JavaScript typedArray.indexOf() Method The typedArray.indexOf() is an inbuilt function in JavaScript which is used to return the index of the element if found in the given typedArray otherwise it returns -1. Syntax: typedarray.indexOf(Element, Index); Parameters: It accepts two parameter which are specified below- Element: It is the elem 2 min read JavaScript typedArray.lastIndexOf() Method The typedArray.lastIndexOf() is an inbuilt function in JavaScript which is used to return the last index of the typedArray at which a given element is present otherwise it returns -1 if the element is not present. Syntax: typedArray.lastIndexOf(search_Element, from_Index]) Parameters: It accepts two 2 min read JavaScript TypedArray.prototype.values() Method TypedArray's values() method returns a new iterator object for the array, this iterator will allow you to traverse through typed arrays and generate the value of each element at every position and like values() method for normal JavaScript arrays, it serves a similar role. SyntaxtypedArray.values()P 1 min read JavaScript typedArray.from() Property The typedArray.from() is an inbuilt function in JavaScript which is used to construct a new typedArray from a normal array or any iterable object. List of different typedArrays are specified in the table below: Int8Array();Int16Array();Uint32Array();Uint8Array();Uint16Array();Float32Array();Uint8Cla 2 min read JavaScript Array of() Method The Javascript array.of() method is an inbuilt method in JavaScript that creates a new array instance with variables present as the argument of the method.Syntax:Array.of(element0, element1, ....)Parameters: Parameters present are element0, element1, .... which are basically an element for which the 2 min read Like