window.app = {};
(function(app) {
app.log = function(data) {
console.log(data);
};
}(app));
app.log("data");
jQuery deals a little bit different with it's fn: as you use $('selector') syntax to find elements you need to process jQuery returns spetial wrapper that contains all the fn.func-like definitions you made in addition to the built-in functions.
So if you need to implement some kind of extensibility you should think over such wrapping first. For example:
window.app = function(p) {
// do whatever you need
var wrapper = {
// standard common fields
};
if (app.fn) {
// extend wrapper with app.fn
}
return wrapper;
};
By the way what problem are you trying to solve?
In your case there is of course an exception because app in not defined by the time anonymous function gets executed.
appdefined? The function takes anappargument and you pass anappvariable, that doesn't exist...