zoukankan      html  css  js  c++  java
  • JavaScript来实现可选参数

    模仿C#4.0中采用方法重写来实现

    最理想的做法是使用在JavaScript中实现方法重载。目前因为只了解ExtJS,借助ExtJS可以实现。完全自己写就就没有想法了。呵呵。

    检验参数
    <script>     
      function   functionName(arg0,   arg1,   arg2,   arg3)   
      { 

      arg0   =   arg0   ==   void   0   ?   0   :   arg0;   
      arg1   =   arg1   ==   void   0   ?   0   arg1;   
      arg2   =   arg2   ==   void   0   ?   0   arg2;   
         arg3   =   arg3   ==   void   0   ?   0   arg3;   
      alert(arg0) 
      alert(arg1) 
      alert(arg2) 
      alert(arg3) 
      } 
      </script> 
      
      <input   type=button   onclick="functionName('a','b')"   value=test>
    使用对象
    function test(options)
    {
      //ref -> options.a
      //ref -> options.b
    }

    test({a:1})

  • 相关阅读:
    TestNG
    K近邻算法
    Python解决乱码问题
    Log4J 配置
    多线程死锁
    hadooplzo安装出错的解决方法
    B树
    设计模式
    整数序列化
    Maven
  • 原文地址:https://www.cnblogs.com/mingle/p/1609114.html
Copyright © 2011-2022 走看看