4

Possible Duplicate:
What does $$ mean in Javascript?

I just saw this piece of code.

var buttons = $$('.add-select-row');

What does that do? Is that Prototype?

Community
  • 1
  • 1
EOB
  • 2,975
  • 17
  • 43
  • 70
  • 3
    http://api.prototypejs.org/dom/dollar-dollar/ – James Allardice Mar 16 '12 at 12:27
  • 2
    Did you check this before asking: http://stackoverflow.com/questions/384873/what-does-mean-in-javascript – Sudhir Bastakoti Mar 16 '12 at 12:28
  • So if I get the doc right, it gets all elemts having the class add-select-row and saves them in the buttons array? – EOB Mar 16 '12 at 12:28
  • 1
    http://stackoverflow.com/q/1463867/601179 – gdoron Mar 16 '12 at 12:29
  • It **could** be Protoype, but it could also be any other library or a custom function which accepts CSS selectors (like `$$ = jQuery.noConflict()`). `$$` is a valid Javascript variable name, so **it could be anything** (without given any context). – Felix Kling Mar 16 '12 at 12:31

6 Answers6

2

Yes it's prototype, and one of the first things in the manual:

http://api.prototypejs.org/dom/dollar-dollar/

Evert
  • 93,428
  • 18
  • 118
  • 189
  • Could also be [MooTools](http://mootools.net/docs/core/Element/Element#Window:dollars) or of unknown origins – Andrew Moore Mar 16 '12 at 12:30
  • You cant for sure say it's Prototype, as out of context it could be any variable. –  Mar 16 '12 at 12:30
  • He tagged the question 'prototype' seems pretty obvious to me – Evert Mar 16 '12 at 12:34
  • @Evert - I agree that he is probably talking about the PrototypeJS function, but that tag is actually referring to the `prototype` in general. There is a separate PrototypeJS tag to refer to that library. Chances are the wrong tag was picked though, so I've retagged it. – James Allardice Mar 16 '12 at 12:36
1

$$ is a variable holding a function (variable names starting with $ are valid in JS).

A few frameworks uses $$ as a shortcut to select multiple elements using a CSS Selector

Andrew Moore
  • 93,497
  • 30
  • 163
  • 175
0

maybe $$ is a no conflict variable of jquery, somewhere in your code you have:

var $$ = jQuery.noConflict();
Luca Rainone
  • 16,138
  • 2
  • 38
  • 52
0

It depends on what libraries are in use on that page. jQuery normally uses $, but so do some other libraries, so common practice is to manually tell the library to use something else instead if you have more than one in use that would otherwise conflict.

This looks like jQuery has been told to use $$ via jQuery.noConflict(), which may mean that $ is in use by Prototype.

Matt Gibson
  • 14,616
  • 7
  • 47
  • 79
0

Yes, seems that this is prototype library.

$$ Takes an arbitrary number of CSS selectors

antyrat
  • 27,479
  • 9
  • 75
  • 76
0

Technically, it does whatever you want it to.

For example, it could be jQuery..

(function($$) {
    // code
})(jQuery);

e: Out of context, there is no definitive answer. You can't for sure say its prototype just because prototype uses dollar-dollar.