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
26
27
28
29
30
31
32
<!DOCTYPE html>
<html>
<head>
    <title>Object Create</title>
</head>
<body>
    <script type="text/javascript">
        var coworkers = { //{}비어 있는 객체
            "programmer" : "egoing",
            "designer" : "leezche"
        };
 
        coworkers.bookkeeper = "duru";
        coworkers["data scientist"= "taeho";
 
        document.write('data scientist->' + coworkers["data scientist"]+'<br>');
        document.write('bookkeeper ->' + coworkers.bookkeeper+'<br>');
        document.write('programmer ->' + coworkers.programmer+'<br>'); 
        document.write('designer ->' + coworkers.designer); 
    </script>
 
    <h2>Iterate</h2>
    
    <script type="text/javascript">
        
        for(var key in coworkers){
            document.write(key+'-> '+coworkers[key]+'<br>');
        }
    
    </script>
</body>
</html>
cs



'JavaScript' 카테고리의 다른 글

⭑버튼을 form밖으로 빼기  (0) 2019.05.30
배열만들고 데이터넣고 꺼내기  (0) 2019.05.25
배열과 반복문  (0) 2019.05.22
반복문  (0) 2019.05.22
배열 만들고 가져오기 기초  (0) 2019.05.22

+ Recent posts