console
var globalVariabel=0;
function test1(){
document.write(localVariable1+'<br/>');
var localVariable1=2
document.write(globalVariabel+'<br/>');
document.write(localVariable1+'<br/>');
}
document.write(globalVariabe2+'<br/>');
test1();
var globalVariabe2=1;
function test2(){
var locaVariable2=3;
}
test2();
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+"年不是润年";
}
}
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>