zoukankan      html  css  js  c++  java
  • 【01】用构造器创建函数中的小知识

    【01】用构造器创建函数中的小知识
     
     
    魔芋:在看ES5.1标准文档时。
    Function (p1, p2, … , pn, body)
     

    NOTE It is permissible but not necessary to have one argument for each formal parameter to be specified. For example, all three of the following expressions produce the same result:

    (为每个形参指定一个参数是允许的,但没必要。例如以下三个表达式产生相同的结果:)

    new Function("a", "b", "c", "return a+b+c") 

    new Function("a, b, c", "return a+b+c") 

    new Function("a,b", "c", "return a+b+c")

     
    魔芋:例子:
    var funa = new Function("a", "b", "c", "return a+b+c");
    var funb = new Function("a, b, c", "return a+b+c");
    var func = new Function("a,b", "c", "return a+b+c");
    
    console.log(funa(1, 2, 3), funb(1, 2, 3), func(1, 2, 3));
    
     
    var a= "moyu";
    var funa = new Function(a, "b", "c", "return a+b+c");
    /* function funa(moyu,b,c){
    
    	return a+b+c;
    }
    */
    var funb = new Function("a, b, c", "return a+b+c");
    var func = new Function("a,b", "c", "return a+b+c");
    
    console.log(funa(1, 2, 3), funb(1, 2, 3), func(1, 2, 3));
    
     
     

    **

  • 相关阅读:
    状态模式
    $和@的特殊处理
    Windows服务调试状态下用Console启动
    AutoResetEvent
    await和async
    计算a,b,c的排列组合
    百度地图:通过经纬度获得位置信息和距离
    装饰模式
    vue+h-ui+layUI完成列表页及编辑页
    为什么memset不能将数组元素初始化为1?
  • 原文地址:https://www.cnblogs.com/moyuling/p/8527942.html
Copyright © 2011-2022 走看看