SOURCE

console 命令行工具 X clear

                    
>
console
var globalVariabel=0;

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

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

 }

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

//打印globalVariable2
document.write(globalVariabe2+'<br/>');
 test1();

 var globalVariabe2=1;

 function test2(){
     var locaVariable2=3;
     //打印localVariable1
    //document.write(localVariable1+'<br/>');
 }
 test2();
 //打印locaVariable2
      //document.write(globalVariabe2+'<br/>');
      //打印globalVariabe1
     document.write(globalVariabel+'<br/>');



document.write('<br/>------------函数的表达式------------------<br/>');
//表达式的调用
    function addsum(a,b){
        return a+b; 
    }
    var k=addsum(5,6);
document.write(k+'<br/>');

document.write('<br/>------------函数的表达式(超链接)------------------<br/>');
function expression(){
    alert("Welcome");
}



    document.write('<br/>------------函数的表达式------------------<br/>');
//润不润年
    function isLeapYear(year){
        //判断是不是润年
        if((year%4==0)&&(year%100!=0)||(year%400==0)){
            return year +"年是闰年";
        }
        else{
            return year+"年不是润年";
        }
    }
    //打印2020,2000,2001是否是润年
    document.write(isLeapYear(2020)+'<br/>');
    document.write(isLeapYear(2000)+'<br/>');
    document.write(isLeapYear(2001)+'<br/>');


    document.write('<br/>------------函数的表达2------------------<br/>');

    function themax(a,b,c,d){
        var max;
        max=(a>b)?a:b;
        max=(max>c)?max:c;
        max=(max>d)?max:d;
        return max;
    }
    document.write("这4个数中最大值为:"+themax(2,5,8,12)+'<br/>');
<!DOCTYPE html> 
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <script>
      function expression()
            {
                alert("hello");
            }
    </script>
</head>
<body>
    <a href="javascript:expression()">打招呼</a>
</body>
</html>