Please explain the meaning of the $ and $$
This is sample code use $ and $$:
what mean this code use $:
var $qtipContainer = $('<div></div>'); 38 Answers
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 Command in the Web Developer Tools Console.
$ 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.
It's jQuery, a JS framework for DOM-manipulation and all sorts of other fun stuff.
$ sign is a valid identifier in JavaScript. $$ was a notation that used back when packer was popular but no significance now.
If you are using prototype javascript then $$() & $() are selectors. For more information visit