• 【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));
    
     
     

    **

  • 相关阅读:
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
    deleted
    CF #505 B Weakened Common Divisor(数论)题解
    HDU 6425 Rikka with Badminton(组合问题签到)题解
    ZOJ 2747 Paint the Wall(离散化+暴力)题解
  • 原文地址:https://www.cnblogs.com/moyuling/p/8527942.html
Copyright © 2020-2023  润新知