-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex7.html
42 lines (42 loc) · 1.2 KB
/
ex7.html
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
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>Object</h1>
<h2>Create</h2>
<script>
// 객체 생성
var coworkers = {
"programmer":"egoing",
"designer":"leezche",
};
// 객체 데이터 가져오기
document.write("programmer : "+coworkers.programmer+'<br>');
document.write("designer : "+coworkers.designer+'<br>');
// 메소드로 객체 추가
coworkers.bookkeeper="duru";
document.write("bookkeeper : "+coworkers.bookkeeper+'<br>');
// 공백 포함 문자열은 [] 사용
coworkers["data scientist"] = "taeho";
document.write("data scientist : "+coworkers["data scientist"]+'<br>');
</script>
<h2>Iterate</h2>
<script>
for(var key in coworkers){
document.write(key+" : "+coworkers[key]+'<br>');
}
</script>
<h2>Property & Method</h2>
<script>
coworkers.showAll = function(){
for(var key in this){
document.write(key+" : "+this[key]+'<br>');
}
}
coworkers.showAll();
</script>
</body>
</html>