Please explain the meaning of the $ and $$
This is sample code use $ and $$: https://github.com/cytoscape/cytoscape.js-qtip/blob/master/cytoscape-qtip.js
what mean this code use $:
var $qtipContainer = $('<div></div>');
Please explain the meaning of the $ and $$
This is sample code use $ and $$: https://github.com/cytoscape/cytoscape.js-qtip/blob/master/cytoscape-qtip.js
what mean this code use $:
var $qtipContainer = $('<div></div>');
The whole code is just a function call with two arguments:
;(function( $, $$ ){ 'use strict';
// skipped
})(
typeof jQuery !== 'undefined' ? jQuery : null,
typeof cytoscape !== 'undefined' ? cytoscape : null
);
The first argument is jQuery
global variable (or null
, if jQuery
is undefined), and the second is cytoscape
global variable (or null
, if is undefined).
In the browser developer tools console - at least in Firefox, IE11, (can't test lesser IE's), Edge and Chrome - $
and $$
do have particular functions (if the page hasn't defined those vars) - see MDN Documentation for helper commands in the Web Console Helpers.
$
and $$
are valid variable names in JavaScript, they have no special meaning.
Usually they set their value to library instances, in your example if you check the closure call, at the end of the file you'll see that $
is jQuery in this case if it is defined and $$
is cytoscape.
See the corresponding code part:
;(function( $, $$ ){ 'use strict';
// ...
})(
typeof jQuery !== 'undefined' ? jQuery : null,
typeof cytoscape !== 'undefined' ? cytoscape : null
);
It's a naming convention in JavaScript for variables that store JavaScript objects. Their name should start with $
. Exactly like in your example:
var $qtipContainer = $('<div></div>');
Because JavaScript is untyped language, this is useful way for programmers to distinguish whether variable stores jQuery object or for example DOM object.
Referring to the source code, $
is jQuery, and $$
is cytoscape.
Besides, the $
symbol is perfectly valid variable name.
If you are using prototype javascript then $$() & $() are selectors. For more information visit https://www.tutorialspoint.com/prototype/prototype_utility_methods.htm
$
and$$
are valid names for variables, they have no special meaning. – Madara's Ghost