zoukankan      html  css  js  c++  java
  • javascript函数 第14节

    <html>
    	<head>
    	<title>function</title>
    	</head>
    	<body>		
    		1.函数形式<br/>
    		<script type="text/javascript">
    			function  test () { 
    				alert('Hello');
    				}  //没有返回值类型声明  function修饰
    			document.write("typeof test :  " , typeof test ,"<br/>");
    			document.write("test  instanceof Function :  " , test  instanceof Function,"<br/>");
    			//调用
    			//test();
    
    			//var  add = new Function("a","b", "alert('2个参数') ;return a + b;");//对象 add是引用
    			//var  result = add(3,5);//函数名
    
    			//document.write("result :  " , result ,"<br/>");
    
    			var  minu = function (a, b) { return a - b};
    
    			result = minu(10,6);//函数名
    
    			document.write("result :  " , result ,"<br/>");
    
    			function add() { //方法是否重载
    				  alert('call add() ....');
    
    			}
    
    			function add(a) { //方法是否重载  没有重载
    				  alert('call add(a) ....');
    
    			}
    
    			function add() { //声明函数 可以没有参数   调用函数 可以传入参数
    				  var a = arguments;//参数数组  调用参数放入arguments
    				  var sum = 0;
    				  for(var i = 0; i < a.length; i++ ) {
    						sum += a[i];
    				  }
    				  return sum;//return 
    			}
    
    			document.write("add() :  " , add(),"<br/>");
    
    			document.write("add(1,5) :  " , add(1,5),"<br/>");
    
    			document.write("add(10,20,30,50,'a',90) :  " , add(10,20,30,50,'a',90),"<br/>");
    
    			document.write("add.toString() :  " , add.toString(),"<br/>");
    
    		</script>     	
    
    	</body>
    
    </html>
    

     rs

  • 相关阅读:
    帝国CMS采集
    帝国CMS常用资料
    IIS 支持PHP(与Apache环境共存)
    Firebug+Firefox 脚本调试
    javascript 参考
    [__NSCFString objectFromJSONString]: unrecognized selector sent to 解决办法
    大家好,我在CSDN开通了博客
    Apple MachO Linker Error
    ios 排序
    ios 二维码生成 扫瞄
  • 原文地址:https://www.cnblogs.com/feilongblog/p/4739827.html
Copyright © 2011-2022 走看看