How to declare variables in jQuery (it is in jQuery, and not in JavaScript, it is desirable to explain all the nuances, including $)?
- var, let and const used in javascript-e are allowed in jQuery?
- In addition to Var, Let and Const What else is used in jQuery?
- In what cases is $?
Answer 1, Authority 100%
var, let and const used in javascript, are allowed in jQuery?
Yes.
At least var
is not desirable to use in new projects. Or with the full understanding of their features compared to Let
and Const
In addition to Var, Let and Const What else is used in jQuery?
No.
jQuery is a library that uses native js , so the rules are exactly the same as even JS
In what cases is $?
My recommendation (and we are doing in the company in projects): All variables related to the object jQuery called that they start with $
. This will give an understanding to other people that, for example, in a variable $ Users
– object jQuery with users, and not js Collection of objects.