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

    **

  • 相关阅读:
    Codeforces Round #642 (Div. 3)
    [P4980] 【模板】Polya定理
    [SCOI2016] 幸运数字
    [P4389] 付公主的背包
    [CF438E] The Child and Binary Tree
    最长异或路径
    [AHOI2013] 作业
    [P4841] [集训队作业2013] 城市规划
    Python 第三方库国内镜像安装
    [CF1202D] Print a 1337-string...
  • 原文地址:https://www.cnblogs.com/moyuling/p/8527942.html
Copyright © 2011-2022 走看看