My js does this:
var MyClass ={
a: 1,
b: 2,
init: function(message){ console.log("calling c to say "+message);};
};
MyClass.init("hello");
//all above code is in js file
I keep seeing the IIFE pattern all over, but I am afraid I don't see what benefit it gets me compared to above. I have a module MyClass and ability to call methods on it. Is there a downside to using this pattern ?
xbecause it's inside the closure. The answer doesn't create a module but it's because the intention is to show what your solution would be lacking, not because it's showing "how to make a module". Given that you claim you know that already, it'd be redundant to go over it again.