Daniel Contreras Daniel Contreras - 2 months ago 9
jQuery Question

In Javascript/JQuery what is $. for?

I'm writing a utility file and I've gotten some examples from online and this a form of writing the utility I've come across:

$.util = $.extend($.util || {}, {

//functions here...

});


and so I think I understand what it's doing. It allows me to call
$.util.function()
somewhere else, however when I remove the
.
in front of the
$
the code breaks. What does this notation mean? What's the difference between
$.
and
$
?

Answer

$.util = something means "assign something to property util of object $".

$util = something means "assign something to variable $util"

Similarly, $.extend is "get value of property extend of object $" (which is a function in this exact scenario) and $extend is "get value of variable $extend"