Blogger Information
Blog 23
fans 0
comment 0
visits 19870
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
练习 js变量、语句、表达式、函数定义及调用、匿名函数--1021
风吹的博客
Original
800 people have browsed it


实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
</body>
</html>
<!-- 练习js变量,语句,表达式 及函数调用-->
<script type="text/javascript">
	//变量用var定义
	//alert在浏览器用弹窗显示
var a = 123;
if(a>100){alert('是个老妖怪');}else{
	alert('是个小伙子')
}

var num = 666;
var num1 = 777;
if(num>num1){alret('大')}else{alert('小')}
//console.log在控制台打印
console.log('大');
//js函数
function x(a,b,c){
	var sum = a+b+c;
	return sum;
}
var res = x(1,2,3);
alert(res);

var c = function (a,b,c){
	var sum = a+b+c;
	return sum;
}
var s = c(6,6,6);
alert(s);

</script>

运行实例 »

点击 "运行实例" 按钮查看在线实例

效果图:10211.png10212.png10213.png10214.png10215.png




在js中定义变量用var,但是在引用变量时不用加var,直接书写变量名即可,alert();会以弹窗形式输出,console.log();会在控制台内打印



Correcting teacher:查无此人查无此人

Correction status:qualified

Teacher's comments:完成的不错,继续努力。
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments