SOURCE

var globalVariable1 = 0;

function test1() {
    document.write(localVariable1+ "<br/>");
    var localVariable1 = 2;
    //打印globalVariable1
    document.write(globalVariable1 + "<br/>");

    //打印localVariable1
    document.write(localVariable1+ "<br/>");
}

//打印localVariable1
//document.write(localVariable1);

//打印globalVariable2
document.write(globalVariable2 + "<br/>");


test1();

var globalVariable2 = 1;

function test2() {
    var localVariable2 = 3;

    //打印localVariable1
    //document.write(localVariable1 + "<br/>");

}
test2();

//打印localVariable2
//document.write(localVariable2 + "<br/>");
//打印globalVariable1
document.write(globalVariable1 + "<br/>");

//超链接调用
function Hello(){
    alert("Hi");
}

//事件调用
function sum(a, b) {
    return a + b;
}

document.write((sum(6, 7) + 3) + "<br/>")


//判断闰年
function isLeapYear(year) {
    var result = false;
    //判断是否是闰年

    if ((year % 4 == 0) && (year % 100 != 0)) {
        result = true;
    }

    if (year % 400 == 0) {
        result = true;
    }

    if (result) {
        document.write( year + " 是闰年 <br/>");
    }
    else {
        document.write( year + " 不是闰年 <br/>");
    }
    

}

//打印2021,2020,2023是不是闰年
isLeapYear(2022);
isLeapYear(2025);
isLeapYear(2028);
console 命令行工具 X clear

                    
>
console