5

I am trying to debug someone's code, and came across this:

$$$.ajax({
    url: ajax_url + param,
    context: $("#formDialog"),
    success: function(data) {
        this.html(data);
        BindPopupFormEvents(this, title, reload);
    }
}, $$$.ajax.PARTAIL_UPDATE, $mainWrapper);​

We are using the jquery library, but I've never seen a triple dollar sign before and I have no clue what it is... any suggestions?

EDIT

I found this later on:

$$$.fn = $$$.prototype = {
    init: function(jQuery, test) {},
    CONST: CONST
};​

We are only using the jquery library, and we use a single dollar sign in most of the code.

can you explain in plain english what the triple dollar sign is accomplishing, please?

gdoron
  • 147,333
  • 58
  • 291
  • 367
esther h
  • 1,468
  • 2
  • 17
  • 35
  • I really have no idea what the "later on" stuff is supposed to do :( –  Jun 10 '12 at 22:33
  • Regarding to your edit: Then it just stupid... unless `$$$` refers to a different jQuery version than `$`., You know what, after second thought, That's stupid as well... `:)` – gdoron Jun 10 '12 at 22:33
  • I know it's more than two years... but I've seen your edit just now... See my updated answer. Sorry for the delay. `:)` – gdoron Oct 01 '14 at 16:51

2 Answers2

7

It's just an alias to the jQuery object, just like $. That's all...

In can be done by hand or with jQuery.noConflict()

Examples:

var $$$ = jQuery.noConflict();
var bla = jQuery.noConflict();

Now both $$$ and bla are aliases to the jQuery object.

Many JavaScript libraries use $ as a function or variable name, just as jQuery does. In jQuery's case, $ is just an alias for jQuery, so all functionality is available without using $. If we need to use another JavaScript library alongside jQuery, we can return control of $ back to the other library with a call to $.noConflict():


Edit to reflect your edit:

Though I see only small portion of the code but $$$.fn = $$$.prototype seems silly as jQuery.fn is an alias to jQuery.prototype...

From the source code:

jQuery.fn = jQuery.prototype
gdoron
  • 147,333
  • 58
  • 291
  • 367
3

$$$ is just a[nother] JavaScript identifier.

The property $$$ is not defined by jQuery, but presumably someone did something like this:

$$$ = jQuery.noConflict();

Perhaps to avoid overwriting a $ from another library. Although I find it to be quite hideous and would opt to just bind $ to jQuery in a closure:

;(function myStuff ($, evil$) {
   // do stuff with $ (jQuery) and "the other $"
})(jQuery, $) // <-- keep us real
  • but we use a single dollar sign all over, why in this one case would we use a triple one? we are only loading the jquery library – esther h Jun 10 '12 at 22:26
  • 1
    @estherh Perhaps code from Dr. Evils Awesome Library uses `$`. Or perhaps a developer thought more money (`$$$`) was better than less money (`$`). I would *not* recommend this approach, though :) –  Jun 10 '12 at 22:26
  • haha :-) i would have chose both yours and gdoron as the "correct" answer, but had to choose only one... thanks for the input though – esther h Jun 11 '12 at 03:43