Last active
May 12, 2018 14:18
-
-
Save khg0712/f69be0d9e52b0e3af43860ea08bf4105 to your computer and use it in GitHub Desktop.
배열 생성 및 접근 예시
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Array 생성자로 배열 생성 | |
var a = new Array(1);//생성자의 인자가 하나일 땐 해당 인자가 배열의 크기가 된다. | |
var b = new Array(1,2,3,4);//생성자의 인자가 여러 개일 땐 인자들이 배열의 요소가 된다. | |
//배열 리터럴로 배열 생성 | |
var c = [1,2,3]; | |
console.log(a[0],a[1]);//undefined, undefined 출력 | |
console.log(b[0],b[1]);//1 2 출력 | |
console.log(c[0],c[1]);//1 2 출력 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment