<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>변수 선언</title>
</head>
<body>
    <h3>변수 선언, 전역/지역/블록 변수</h3>
    <hr>
    <script>
    let x;
    function f() {
        let y;
        x = 10;
        y = 20;
        z = 30;
        if(y == 20) {
            let b = 40; 
            b++;
            document.write("if 블록 내 블록변수 b = " + b + "<br>");
        }
    document.write("함수 f() 내 지역변수 y = " + y + "<br>");
    }
    f();
    document.write("전역변수 x = " + x + "<br>");
    document.write("전역변수 z = " + z);
    </script>
</body>
</html>
<!DOCTYPE html>
<html lang="ko"?
<head>
    <meta charset="utf-8">
    <title>리터럴</title>
</head>
<body>
    <h3>리터럴</h3>
    <hr>
    <script>
        let oct = 015;
        let hex = 0x15;
        let condition = true;

        document.write("8진수 015는 십진수로 " + oct + "<br>");
        document.write("16진수 015는 십진수로 " + hex + "<br>");
        document.write("condition은 " + condition + "<br>");
        document.write('문자열 : 단일인용부호로도 표현' + "<br>");
        document.write("그녀는 \"누구세요\"라고 말했습니다.");
    </script>
</body>

'----------고1---------- > 화면구현' 카테고리의 다른 글

[고1 화면구현] 11 - (1)  (0) 2023.11.09
[고1 화면구현] 10 - (4)  (0) 2023.10.26
[고1 화면구현] 10 - (3)  (0) 2023.10.19
[고1 화면구현] 10 - (2)  (1) 2023.10.10
[고1 화면구현] 10 - (1)  (0) 2023.10.05