<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
var a = Array(3);
a[0]=10;
a[1]=20;
document.write(a.length+"<br>");
for(var i=0;i<a.length;i++){
document.write(a[i]+" ");
}
document.write("<br>");
var b=new Array('one','two','three');
document.write(b.length+"<br>");
for(var i=0;i<b.length;i++){
document.write(b[i]+" ");
}
document.write("<br>");
for(n in b){
document.write(b[n]+"<br>");
}
document.write("<br>");
var c = Array(3,4,5); //2개 이상 쓰면 방의 갯수가 아닌 들어갈 값이 된다.
document.write(c.length+"<br>");
for(var i=0;i<c.length;i++){
document.write(c[i]+" ");
}
document.write("<br>");
var d=['rose','tulip','lily',"cosmos"];
for(var i=0;i<d.length;i++){
document.write(d[i]+" ");
}
document.write("<br>");
document.write(d+"<br>"); //주소가 아닌 내용이 출력
document.write(d.toString()+"<br>"); //위와 같다.
for(f in d){ //확장 for 문
document.write(f+"/"+d[f]+"<br>");
}
var e=[123,0.98,"javascript",d];
for(x in e){
document.write(e[x]+"<br>");
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
var a= new Array('kim','shin','park');
var b= ['lee','son','choi','won'];
var all= a.concat(b);
document.write(all+"<br>");
document.write(all.length+"<br>");
var sliceArr= all.slice(1,3);
document.write(sliceArr+"<br>");
allSort= all.sort();
document.write(allSort+"<br>");
allSortReverse = allSort.reverse();
document.write(allSortReverse+"<br>");
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
/* var arr = new Array(2);
arr[0] = new Array(10,20,30);
arr[1] = new Array(40,50,60,70);
*/
/* var arr=new Array(2);
arr[0] =new Array();
arr[1] =new Array();
arr[0][0] = 10;
arr[0][1] = 20;
arr[1][2] = 60;
arr[1][3] = 70;
*/
var arr=[
[10,20,30],
[40,50,60,70,80]
];
for(var i=0;i<arr.length;i++){
for(var j=0;j<arr[i].length;j++){
document.write(arr[i][j]+" ");
}
document.write("<br>");
}
document.write("<br>");
for(i in arr){
for(j in arr[i]){
document.write(arr[i][j]+" ");
}
}
</script>
</head>
<body>
</body>
</html>