zoukankan      html  css  js  c++  java
  • js 函数定义三种方式

    今天看到js原来有很多种定义的方式

    var region = new Object();
    region.isAdmin = false;
    region.loadRegions = function(b, a, c) {
    Ajax.call(region.getFileName(), "type=" + a + "&target=" + c + "&parent=" + b, region.response, "GET", "JSON")
    };

    region.getFileName = function (){

      if (region.isAdmin) {
        return "../region.php"
      } else {
        return "region.php"
    }

    }

    这段代码是选择城市的一段代码
    <script type="text/javascript"> function add(num1,num2) { return num1+num2+200;} var sum=add(122,10000); window.document.write(sum); </script> <script type="text/javascript"> var add=new Function("num"," return num+200");    //此时Function 这种方法用的比较少 var sum=add(122); window.document.write(sum); </script> <script type="text/javascript"> var add=function(num1,num2){ return num1+num2+200;} var sum=add(122,300); window.document.write(sum); </script>
  • 相关阅读:
    python note 30 断点续传
    python note 29 线程创建
    python note 28 socketserver
    python note 27 粘包
    python note 26 socket
    python note 25 约束
    Sed 用法
    python note 24 反射
    python note 23 组合
    python note 22 面向对象成员
  • 原文地址:https://www.cnblogs.com/jasonxu19900827/p/5335267.html
Copyright © 2011-2022 走看看