array.from
-
Array.from()Study/JavaScript 2020. 6. 13. 13:06
Array.from() 메서드는 유사 배열 객체(array-like object)나반복 가능한 객체(iterable object)를 얕게 복사해 새로운Array 객체를 만든다. console.log(Array.from('foo')); // expected output: Array ["f", "o", "o"] console.log(Array.from([1, 2, 3], x => x + x)); // expected output: Array [2, 4, 6] 구문 Array.from(arrayLike[, mapFn[, thisArg]]) 매개변수 arrayLike : 배열로 변환하고자 하는 유사 배열 객체나 반복 가능한 객체 mapFn : 배열의 모든 요소에 대해 호출할 맵핑 함수 thisArg : mapF..