TypeScript Array.of() Method Last Updated : 22 Jul, 2024 Comments Improve Suggest changes Like Article Like Report The Array.of() method in TypeScript is used to create a new array from a variable number of arguments, regardless of the data types of those arguments. This inbuilt function provides a straightforward way to create arrays with the specified elements.SyntaxArray.of(items)Parametersitems: Here you can pass several elements without taking care of their data types. Return ValueIt returns a new array containing elements that you have passed as arguments in the method. Examples of TypeScript Array.of() MethodExample 1: Basic ImplementationIn this example, we use the Array.of() method to create an array from a series of numeric arguments. JavaScript const geeks:number[]= Array.of(1,2,3,4); console.log(geeks) Output:[1, 2, 3, 4]Example 2: Array with Different Data TypesIn this example, we create an array containing elements of various data types using the Array.of() method. JavaScript const geeks:(number|strin|boolean)= Array.of(1,"GFG",true, 8.14); console.log(geeks) Output:[1, 'GFG', true, 8.14] Comment More infoAdvertise with us Next Article TypeScript Array.of() Method pankajbind Follow Improve Article Tags : JavaScript Web Technologies TypeScript Similar Reads TypeScript Array indexOf() Method The Array.indexOf() method in TypeScript is used to find the index of the first occurrence of a specified element in an array. If the element is not found, it returns -1.Syntaxarray.indexOf(searchElement[, fromIndex])Parameter: This method accepts two parameters as mentioned above and described belo 2 min read TypeScript Array entries() Method The Array.prototype.entries() method in TypeScript returns a new array iterator object that contains the key/value pairs for each index in the array. This method is useful when you need to iterate over the key/value pairs in the array.Note: In TypeScript, the entries() method is not available direct 2 min read TypeScript Array lastIndexOf() Method The Array.prototype.lastIndexOf() method in TypeScript is used to find the last index at which a given element can be found in the array, searching backwards from the fromIndex. It returns the index of the found element, or -1 if the element is not present.Syntax:array.lastIndexOf(searchElement[, fr 2 min read TypeScript Arrays An array is a user-defined data type. An array is a homogeneous collection of similar types of elements that have a contiguous memory location and which can store multiple values of different data types.An array is a type of data structure that stores the elements of a similar data type and consider 5 min read TypeScript Object The Array Type In TypeScript, the Array Type is used to specify and enforce the type of elements that can be stored in an array, enhancing type safety during development. This adaptability ensures reusability across diverse data types, as exemplified by the Array type (e.g., number[] or string[]). Syntaxlet myArra 2 min read How To Get Types From Arrays in TypeScript? In TypeScript, arrays are a common data structure, but sometimes it's necessary to extract the types of elements stored in an array for type-checking or validation purposes. TypeScript provides several ways to extract types from arrays, enabling more type-safe operations.We will explore different me 3 min read Typescript Generic Type Array A generic type array is an array that is defined using the generic type in TypeScript. A generic type can be defined between the angled brackets(<>). Syntax:// Syntax for generic type arraylet myArray: Array<Type>;Example 1: Creating a simple generic type array of number type in Typescri 1 min read 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.of() Method 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 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