JavaScript/Built-in Method etc.
new Array()
감공사
2019. 12. 29. 23:35
728x90
✨ 원하는 개수만큼 array를 선언하는 방법
(e.g., const arr = new Array(100)) 왼쪽처럼 선언하면 간단하게 100개의 array를 생성할 수 있다.
💻Example Code
const arr = new Array(100);
console.log( arr );
console.log( arr.length);
😋 가끔 큰 index의 Array를 다룰 때, undefined보다는 하나의 값을 전체적으로 지정해주고 싶을 때가 있다. 그때 사용하면 된다.
백준 4673 셀프 넘버(Self Number)에서 유용하게 사용했다.
👉 자세한 내용은 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
Array
The JavaScript Array class is a global object that is used in the construction of arrays; which are high-level, list-like objects.
developer.mozilla.org