![]() |
VOOZH | about |
The Array.from() method is used to create a new array from any iterables like array, objects, and strings.
[ 'G', 'e', 'e', 'k', 's', 'f', 'o', 'r', 'G', 'e', 'e', 'k', 's' ]
Syntax
Array.from(object, mapFunction, thisValue);Parameters
It returns a new array from the iterable passed as argument.
We have a complete list of Javascript Array methods, to check those please go through this Javascript Array Complete reference article.
We can use Array.from() method to create or convert the given set to the array.
[ 10, 20, 30 ]
It can create array from the keys, values and also from each entry of the object.
[ 'a', 'b', 'c', 'd', 'e' ] [ 10, 20, 30, 40, 50 ] [ [ 'a', 10 ], [ 'b', 20 ], [ 'c', 30 ], [ 'd', 40 ], [ 'e', 50 ] ]
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.