(function () { console.log("first"); $ = function (){ console.log("second"); } })() /*without the $= part in the other example, $() can be invoked outside the function*/