There is a following possible syntax:
It returns a newly created array.
Note: Array from() method allows to create a new array from an array-like object, specified with a length property and indexed elements. The length property of the from() method is 1 usually.
Let's see the below examples to understand better:
Here's a simple example to create an array from a string.Test it Now
In the output displayed, it is clear that each letter of the string gets converted to an array element.
Here's an example to create an array from an array-like object.Test it Now
Here's an example to convert a given Set into an array.Test it Now
In the output, we can see that each value occurred only once.
Note: A set is a collection of values that occur only once in the resultant/output. Such behavior maintains the uniqueness of each value present in the set.
Here's an example of generating a sequence of numbers using length property.Test it Now