Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean $ and $$ in javascript?

Tags:

javascript

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>');
like image 650
zngDuong Avatar asked Oct 06 '16 07:10

zngDuong


2 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).

like image 178
Ruslan Osmanov Avatar answered Sep 22 '22 07:09

Ruslan Osmanov


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.

like image 28
Jaromanda X Avatar answered Sep 24 '22 07:09

Jaromanda X