On 3/4/06, Eric H. Jung <[EMAIL PROTECTED]> wrote: > I could do it easily only if I understood the code at > http://www.json.org/json.js. I don't > understand this syntax: > > var JSON = function () { > var m = {...}, > ..., > return { > stringify: function (v) {} > }; > }(); > > What the heck is that? That's about as comprehesible as > http://www0.us.ioccc.org/2004/gavare.c > > You're working with JS for quite a long time already; that syntax shouldn't confuse you anymore. They are just using a closure to hide their internal variables ("m") from the global scope. Those variables are still accessible to methods of the object returned from the anonymous function. The (function() {}) () syntax is understandable too - they're declaring a function and calling it in one statement.
Nickolay _______________________________________________ Project_owners mailing list [email protected] http://mozdev.org/mailman/listinfo/project_owners
