Do I need to put a dollar before variable names with javascript?

前端 未结 4 1091
终归单人心
终归单人心 2021-01-11 18:19

I have the following code:

var formSubmitHandler = function (link, form) {

    //e.preventDefault();
    var $form = form;
    var val = $form.valid();
             


        
4条回答
  •  庸人自扰
    2021-01-11 18:49

    No, you don't have to use the $ sign. It's just an aesthetic choice usually.

    In your example code above, the function's argument is named form function (link, form). Inside the function, the new variable being declared has a $ to it so as to distinguish it from the argument variable form.

提交回复
热议问题