js函数语法

时间:2014-05-23 05:21:07   收藏:0   阅读:252

  <script type="text/javascript">
    //1 普通方法
  /*
   *  function 方法名(参数){
   *   方法体
   *  }
   */
//  function add(a,b){
//   return a+b;
//  }
//  alert(add(1,1));
  
  //2 构造函数方式
  /*
   * var 变量名 = new Function(参数n,方法体);
   */
//  var add = new Function(‘a‘,‘b‘,‘return a+b;‘);
//  alert(add(1,2));
  
  //3 直接量方式
  /*
   * var 变量名 = function(参数){
   *   方法体
   * }
   */
  var add = function(a,b){return a+b;}
  alert(add(1,3));
  </script>

js函数语法,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!