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

前端 未结 4 1093
终归单人心
终归单人心 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:43

    That is not neccessary. The dollar sign before a variable is most of the times used as an indication it is a JQuery variable. JQuery uses the dollar sign as a shortcut. Using it in a variable name has no extra meaning other than the aesthetic meaning for the developer that it is a JQuery object.

提交回复
热议问题