mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-25 21:16:21 +00:00
23 lines
519 B
Markdown
23 lines
519 B
Markdown
---
|
|
date: 2020-11-13
|
|
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']
|
|
```
|