console
document.write('<br/>');
var globalVariable1 = 0;
document.write(globalVariable2);
function test1(){
var localVariable1 = 2;
document.write(globalVariable1 + "<br/>")
document.write(localVariable1 + "<br/>");
}
test1();
var globalVariable2 = 1;
function test2(){
var localVariable2 = 3;
}
test2();
document.write(globalVariable1 + "<br/>");
function welcomeMes(){
alert("Welcome!")
}
function add(left,right){
return left + right;
}
document.write((add(1,2)+3)+"<br/>")
function isLeapYear(year) {
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
return year + "是闰年";
}
else{
return year + "不是闰年";
}
}
document.write(isLeapYear(2020));
document.write('<br/>');
document.write(isLeapYear(2000));
document.write('<br/>');
document.write(isLeapYear(2001));
document.write('<br/>');
function getMax(a,b,c,d,e) {
var maxNum;
maxNum = (a > b) ? a : b;
maxNum = (maxNum > c) ? maxNum : c;
maxNum = (maxNum > d) ? maxNum : d;
maxNum = (maxNum > e) ? maxNum : e;
return maxNum;
}
document.write("5个数中的最大值为:" + getMax(165, 26, 34, 47, 5));
document.write('<br/>');
function getMin(a,b,c,d,e) {
var minNum;
minNum = (a > b) ? b : a;
minNum = (minNum > c) ? c : minNum;
minNum = (minNum > d) ? d : minNum;
minNum = (minNum > e) ? e : minNum;
return minNum;
}
document.write("5个数中的最小值为:" + getMin(5, 675, 7, 334, 9));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
function welcomeMes()
{
alert("Welcome");
}
</script>
</head>
<body>
<a href="javascript:welcomeMes()">欢迎</a>
</body>
</html>