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.
Example: Here, Array.of()
method is used to create new array instances with a variable number of arguments.
Javascript
// Here the Array.of() method creates a new Array instance with // a variable number of arguments, regardless of // number or type of the arguments. console.log(Array.of(0, 0, 0)); console.log(Array.of(11, 21, 33)); console.log(Array.of( "Ram" , "Geeta" ));
console.log(Array.of( 'geeksforgeeks' ));
console.log(Array.of(2, 3, 4, 'Sheeta' ));
|
Output
[ 0, 0, 0 ] [ 11, 21, 33 ] [ 'Ram', 'Geeta' ] [ 'geeksforgeeks' ] [ 2, 3, 4, 'Sheeta' ]
Recommended Articles