[JS] Day02.

카테고리 없음 2018. 4. 4. 22:25 |
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html>
<head>
    <title></title>
    <script type="text/javascript"
    // 1. 호환을 위해 그냥 이렇게 적어두는것이 좋다
    document.write("1. first javascript!");
    document.write("<br>");
 
 
    // 2.
    var arrNumber = new Array();
 
    arrNumber[0= 1;
    arrNumber[1= 2;
    arrNumber[2= 3;
    arrNumber[3= 4;
    arrNumber[4= 5;
 
 
    for (var i = 0; arrNumber.length > i; i++
    {
        document.write("<br>");
        document.write(arrNumber[i]);
    }
    
    document.write("<br>");
    document.write("<br>");
 
    // 3. try-catch
    var firstName = "도현";
 
    try
    {
        document.write("내 이름은 " + lastName + "입니다");
    }
    catch(ex)
    {
        document.write(ex.message);
    }
        // document.write("<br>");
        // document.write(message);
 
        // document.write(firstName);
        // document.write("<br>");
        // document.write(lastName);/* */
    document.write("<br>");
    document.write("<br>");
 
 
    // 4. 
    function sayHello()
    {
        document.write("4. My javascript");
    }
    sayHello();
 
    document.write("<br>");
    document.write("<br>");
 
    // 5-1 ????
    function add1(num1,num2)
    {
        document.write(num1+"+"+num2+"="+(num1+num2));
    }
    add1(1,3);
 
    document.write("<br>");
    document.write("<br>");
 
    // // 5-2.
    // function add(num1,num2)
    // {
    //     return num1+num2;
    // }
    // var result = add(1,3);
    // document.write("5. 1+3 = " + result + "입니다.")
 
 
    // 6. 알림창
    //alert("Hi");
 
    // 7. prompt(제목,내용)
    // var userInput = prompt("Name?","");
    // alert(userInput + ", Nice to meet you!")
 
    // 8. 선택창 confirm
    /*var result = confirm("2017년에 이루고자?");
    if(result)
    {
        alert("Yes");
    }
    else
    {
        alert("No");
    }
*/
    // 9. 팝업 window.open(주소,이름,속성)
    // window.open("http://www.naver.com","popup1",
    //     "left=0,top=0,width=500,height=300,location=yes,status=no");
 
    // 10. 함수호출 시간 setInterval(함수명, 시간) / setTimeout(함수명, 시간)
    // var i=0;
    // var timer = 0;
    // timer = setInterval(sayHello, 3000); // 3초마다 총 6번 불러짐
 
    // function sayHello()
    // {
    //     alert("Hi, i'm javascript");
    //     i++;
    //     if(i==5)
    //     {
    //         clearInterval(timer);
    //     }
    // }
    
    // 11. 
    var s = "javascript";
    s.strike();
    "javascript".strike();
 
    </script>
</head>
<body>
 
</body>
</html>
cs


Posted by 너래쟁이
: