mirror of
https://github.com/alrayyes/wiki.git
synced 2024-12-01 15:26:23 +00:00
22 lines
502 B
Markdown
22 lines
502 B
Markdown
---
|
|
id: 5ec66270-20b0-466e-85ea-dd7472a84880
|
|
title: Array.from()
|
|
---
|
|
|
|
# Syntax
|
|
|
|
``` javascript
|
|
const arr2 = Array.from(arguments);
|
|
```
|
|
|
|
If a value is [iterable](20201014092625-javascript_iterables) (as all
|
|
Array-like DOM data structure are by now), you can also use the
|
|
[spread](20201014094144-spread) operator (…) to convert it to an
|
|
[Array](20200826201029-arrays):
|
|
|
|
``` javascript
|
|
const arr1 = [...'abc'];
|
|
// ['a', 'b', 'c']
|
|
const arr2 = [...new Set().add('a').add('b')];
|
|
// ['a', 'b']
|
|
```
|