+ 5
Variable syntax - Jquery
I was seeing jquery codes. Then I realized that in the syntax of variables I had a $ in the word type: var $obj; I thought I had a mistake. I tried to use it and it worked, but how could it have worked out if special characters are invalid in creating the variable name? Is this an exclusive property of jQuery? What is the difference between a normal name and a with $?
5 Respuestas
+ 2
Go to the sololearn lesson about naming variables in JavaScript. It says that a variable name must start with a letter, underscore or dollar sign. There's nothing special with variables that have a dollar sign in their names. For example, the jQuery $ it's just a regular function.
+ 7
You probably misunderstood the syntax of jquery..
https://www.w3schools.com/jquery/jquery_syntax.asp
+ 6
@Luis Lopes valeu man... Agora tudo faz sentido...
+ 4
@Md. Nafis UI Haque Shifat It's about the name of the variables that could have the $ sign. Example:
var $var1 = 123;
var $var2 = 123;
var $var3 = 123;
The above example works in jQuery, even though it contains the $ sign. Why is this valid?
+ 2
@David De nada, eu também pensava que era algo especial