5

I've seen this, using "$$", for instance:

[].forEach.call($$("*"), function(a) {
 a.style.outline =
   "1px solid #" + (~~(Math.random() * (1 << 24))).toString(16);     

function Main() {
   [].forEach.call($$("*"), function(a) {
     a.style.outline =
       "1px solid #" + (~~(Math.random() * (1 << 24))).toString(16);     
   });
   //sorry, didn't find credit, but thanks to author
 }

 $(document).ready(function() {
   //Main();
 });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>Some Text</div>

unfortunately, searching for $$ anywhere (google, yahoo, jquery site, jquery file, stackexchange) on the web return no result.

I can see what it does, but would like to know where it comes from?

And am also interested in how I could have found the answer by myself, because I can't google it or look it up in the jQuery API documentation. thanks

Edit:

  • it's not a duplicate of JavaScript Double Dollar Sign . I'm talking about the $$ variable, actually assigned to something even in a blank page without any js loaded. Opening chrome console and typing $$ should allow someone to answer
  • (wondering why no search engine can return a result when searching for $$)
Community
  • 1
  • 1
user1657853
  • 141
  • 5
  • 4
    It's two dollarsigns, one after the other. It's also a valid variable, and can be anything ? – adeneo Dec 16 '15 at 11:48
  • 3
    Maybe you should find `var $$ = jQuery.noConflict();` in your code – Tushar Dec 16 '15 at 11:48
  • It's a local assignation of jQuery, to a variable named `$$` – Mitya Dec 16 '15 at 11:48
  • 1
    I’ve seen it a few times as an alias to `document.querySelectorAll`. – Raphael Schweikert Dec 16 '15 at 11:49
  • 5
    @Quentin This is not a duplicate I think. Most likely OP's encountered webkit Command Line API shortcut for document.querySelectorAll. https://developer.chrome.com/devtools/docs/commandline-api#selector_1 – dfsq Dec 16 '15 at 11:52
  • http://stackoverflow.com/a/1463903/19068 (one of the answers on the duplicate) definitely answers this. Speculating on what context the code is used in which might determine what value is actually assigned to the `$$` variable is … speculation. – Quentin Dec 16 '15 at 11:53
  • 1
    The “Prototype” framework has a [`$$` function](http://api.prototypejs.org/dom/dollar-dollar/) that uses its own CSS query selector engine (which acts similarly to `document.querySelectorAll`). You can test if the prototype library is included on your site using `"Prototype" in window`. – Raphael Schweikert Dec 16 '15 at 11:56
  • 1
    Oh, and by the way: Prototype is the first result on Google when searching for “dollar-dollar javascript”. That’s how you could have found the answer by yourself. – Raphael Schweikert Dec 16 '15 at 12:00
  • 1
    If you want to use special character in your search, try [SymbolHound](http://symbolhound.com/) – Jaap Dec 16 '15 at 13:19
  • 2
    Related: http://stackoverflow.com/questions/8981211/what-is-the-source-of-the-double-dollar-sign-selector-query-function-in-chrome-f – Quentin Dec 16 '15 at 13:22
  • Thanks to all, got it. And with symbolhound it's now easy, great. – user1657853 Dec 16 '15 at 13:29

0 Answers0