5

I am working on a project, in that they have used $$ to select an id/class. I am not sure about this. Can anybody tell me what does this mean. I googled it. But did not get proper answer.

$$("#" + idName + "text").setStyle('background', '#000');
Mi-Creativity
  • 9,554
  • 10
  • 38
  • 47
Green Computers
  • 723
  • 4
  • 14
  • 24
  • I know that $$ in google chrome is the shorthand for `document.querySelectorAll`, but for use in jQuery? I don't think it makes a difference, but I can't substantiate that. – evolutionxbox Aug 04 '16 at 10:11
  • 1
    Possible duplicate of [JavaScript Double Dollar Sign](http://stackoverflow.com/questions/1463867/javascript-double-dollar-sign) – hsz Aug 04 '16 at 10:12
  • Can you post more JS? Specifically the IIFE arguments? – evolutionxbox Aug 04 '16 at 10:12
  • @hsz - I don't think it is a duplicate. That question was asking about a variable name with `$$` whereas this looks like a function library usage. – evolutionxbox Aug 04 '16 at 10:14
  • Thank you all. Now i need to find which js library file uses $$ in my project. – Green Computers Aug 04 '16 at 10:18
  • This could be because the code is using the Prototype library. See https://stackoverflow.com/questions/36004225/what-does-mean-in-prototype-and-what-is-its-equivalent-in-jquery – James Westgate Mar 24 '21 at 07:47

3 Answers3

3

It's simply some library shorthand. Like jQuery assigns itself variable $, some other library may assign $$ to itself to avoid conflicting with jQuery

Justinas
  • 41,402
  • 5
  • 66
  • 96
1

In Javascript $ is a valid variable name, as is $$ and $$$. While you see it mostly used with jQuery, this is not unique to jQuery.

As another answer says, the project you're working with likely has a library which has assigned something to $$.

$ can also be used in variable names like this:

$foobar
foo$bar
0

Looking at $$("#" + idName + "text"), the double $ doesn't make any sense to me but would be error in your code as jQuery shorthand alias is just a single $ and when you use $$(selector) would make no sense.

But obviously you can assign the $$ or anything that is valid identifier to work with jQuery to make it no-conflict like below:

var $$ = jQuery.noConflict();
$$(selector); //now here $$ is jQuery alias with no problem

So, I suppose your code is using some library shorthand method jQuery alias as $$.

Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231