@챈챈/#JavaScript

[JavaScript] JS기초 - 배열 값 가져오기

자바장인 2020. 1. 10. 16:07
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
</head>
 
<body>
    <script>
        var arr = [30"안녕하세요"true];
 
        document.write("<h3>배열값 가져오기 1</h3>");
        for (var i = 0; i <= arr.length - 1; i++) {
            document.write(arr[i], "<br>");
        }
        document.write("<h3>배열값 가져오기 2</h3>");
        for (i in arr) {
            document.write(arr[i], "<br>");
        }
    </script>
</body>
 
</html>
 

배열 객체에 저정된 값들을 출력하는 방법입니다.

배열 출력 결과입니다.