search

Home  >  Q&A  >  body text

javascript - Are there any popular names for actual parameters and formal parameters? Especially formal parameters

I have never understood it. For actual parameters, I will add $ in front of the jquery object and use camel case to name it. For other string arrays, I will use str/arr and use camel case to name it. This actual parameter is not bad. I don’t know how to name the key formal parameters. Sometimes I name them the same as the actual parameters. For example, the actual parameter is $this=$(this), and my formal parameter is $this or obj/ele. I don’t know how to name it. I found that other people named them differently, which was very confusing. Also, maybe there is something wrong with my understanding of actual parameters and formal parameters. For example, $(this) in var $this=$(this) is an actual parameter, and the x in function funName (x){} is a formal parameter, which is Do you understand this?

ringa_leeringa_lee2742 days ago1006

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-07-05 10:59:24

    There are no rules, just name it whatever you want, don’t violate the basic naming rules.

    function a(param) {  // param形参
        console.log(param);
    }
    a(123); // 123实参

    reply
    0
  • typecho

    typecho2017-07-05 10:59:24

    You can understand that the formal parameter is the definition of the method or function, and the actual parameter is the parameter passed when calling the method or function. This parameter is the actual parameter. The actual parameter will be received by the formal parameter defined by the function or method. It is that simple. !

    reply
    0
  • Cancelreply