How is jQuery’s $ a function and an object?

This isn’t unique to jQuery, but an aspect of javascript. All functions are objects. E.g.:

var f = function() { alert('yo'); }
f.foo = "bar";

alert(f.foo); // alerts "bar"
f();          // alerts "yo"

Leave a Comment