Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- for loop
- keyup
- Dom
- CSS
- css:position
- keyboardEvent
- addEventListener
- react
- nodeValue
- UI
- modal
- Temporal dead zone
- yet
- textContent
- beforeinput
- Empty
- dotenv
- a11y
- Event
- javascript
- es6
- TypingEffect
- ES5
- js
- innerText
- innerHTML
- HTML
- node.js
- Review
- node
Archives
- Today
- Total
the murmurous sea
JS ES6: Array.from() 본문
1. method
2. creates a new, shallow-copied Array instance from an array-like or iterable object.
3. The length property of the from() method is 1.
4. In ES2015, the class syntax allows sub-classing of both built-in and user-defined classes.
: As a result, static methods such as Array.from() are "inherited" by subclasses of Array, and create new instances of the subclass, not Array.
[Syntax]
Array.from(arrayLike [, mapFn [, thisArg]])
// has the same result as Array.from(obj).map(mapFn, thisArg)
// except that it does not create an intermediate array.
arrayLike | An array-like or iterable object to convert to an array. | |
- array-like objects: objects with a length property and indexed elements. | ||
- iterable objects: objects such as Map and Set. | ||
mapFn | optional | Map function to call on every element of the array. Which allows you to execute a map() function on each element of the array being created. |
thisArg | optional | Value to use as this when executing mapFn. |
[Return Value]
A new Array instance.
[Examples]
1. Array from a String
2. Array from a Set
3. Array from a Map
4. Array from an Array-like object (arguments)
5. Using arrow functions and Array.from()
6. Sequence generator (range)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from
'#dev > 개념정리' 카테고리의 다른 글
JS: match() vs includes() (0) | 2020.06.24 |
---|---|
JS: instance? (0) | 2020.06.10 |
Event: keydown, keypress, keyup (0) | 2020.06.05 |
JS ES6: Hoisting, Temporal dead zone (0) | 2020.06.03 |
JS: about Event (0) | 2020.06.03 |
Comments