javascript - How does jQuery makes the jQuery object both a function and an object property? -


i've been wondering long time how jquery can both function , object property.

you can use function, jquery(...) , can use property jquery.ajax(...)

how can achieve such thing in javascript?

functions objects in javascript. can have main function

var $ = function() {  alert('wat'); } 

and extend it

$.fadeto = function() { alert('fadeto'); } 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -