JS/Javascript
Array.from() 정리 (JavaScript)
싸공
2020. 8. 6. 16:17
<script>
let arr1 = Array.from('Hello');
console.log(arr1);
console.log("type : " + typeof(arr1));
let arr2 = Array.from([1, 2, 3, 4], x => x + x);
console.log(arr2);
console.log("type : " + typeof(arr2));
let arr3 = Array.from({
0 : 'one',
1 : 'two',
2 : 'three',
length : 3
});
console.log(arr3);
console.log("type : " + typeof(arr3));
</script>
문자열, 배열, 객체를 Array 오브젝트로 반환한다.