第六次网页

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>函数</title>
	</head>
	<body>
		<script type="text/javascript">
		function fn01(a,b){
			console.log(a+b);
		}
		console.log(fn01);
		var fn02=function(a,b){
			console.log(a+b);
		}
		var fn03 = new Function('a','b','return (a+b);');
		function fn04(a,b){
			return (a+b);
		}
		console.log("==================");
		function test01(x,y){
			console.log(x+y);
		}
		test01();
		test01(1);
		test01(1,2);
		function test02(x,x){
			console.log(x);
		}
		test02(1,2);
		function test03(x){
			x= x||"x";
			console.log(x);
		}
		test03(10);
		test03();
		function test04(x){
			(x !=null && x !=undefined)?x=x:x="x";
			console.log(x);
		}
		test04();
		test04("hello");
		var num =10;
		function test05(num){
			num=20;
		}
		test05(num);
		console.log(num);
		
		var obj={name:"zhangsan"};
		console.log(obj);
		function test06(o){
			o.name = "lisi";
		}
		test06(obj);
		console.log(obj);
		console.log("==================");
		
		function f1(){
			console.log("常用调用模式...");
		}
		f1();
		var f2= function(a){
			console.log("函数调用模式...");
			return a;
		}
		var num1= f2(1);
		console.log(num1);
		var obj={
			name:"zhangsan",
			age:18,
			sex:true,
			cats:["大毛","二毛"],
			dog:{
				name:"张二狗",
				age:1
			},
			sayhello:function(){
				console.log("你好呀~");
			}
		}
		console.log(obj);
		console.log(obj.dog);
		console.log(obj.sayhello);
		obj.sayhello();
		
		console.log("==================");
		function a1(){
			console.log("没有返回值...");
			return;
			console.log("---------");
		}
		console.log(a1());
		
		function a2(){
			console.log("有返回值...");
			return "test";
		}
		console.log(a2());
		console.log("==================");
		var pp = "hello";
		function qq(){
			var box1= 10;
			box2 = 20;
		}
		qq();
		console.log(pp);
		//console.log(box1);
		console.log(box2);
		
		</script>
	</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值