js 中,一切都是对象,function也一样。 关于function 写法 ,可以,将最后一个参数作为方法体。或者

  1. var add = function(num,num1)  
  2. {  
  3. }  
  4.  
  5. function add(num,num1)  
  6. {  

每个方法中都有一个隐式的arguments参数

 

<html>
 <head>
 </head>
 <body>
<script type="text/javascript">
  new function test() 
  {   
   if (arguments.length == 1)   
   {
    alert("here");
    alert(arguments[0]);   
   }   
   else if (arguments.length == 2)
       {
    alert(arguments[0]);
    alert(arguments[1]);
       }   
   else if (arguments.length == 3)   
   {   
   } 
  }

test(67);

test(10, 20);
</script>
 </body>
</html>