I've realized you can have a property in an object run automatically like this:
var obj = {
init:(function(){ alert('loaded');})();
}
I'm trying to use this method as an initializer for the object. The problem I'm running into is passing a reference to 'obj' to the init property. I suspect it generates errors because the obj hasn't been completely built in browser yet. I'm trying to do the following, but unsuccessfully. If there's a way to do this, I'd love to know how.
var obj = {
prop:function(){ alert('This just ran.'); },
init:(function(){ obj.prop(); })();
}