D
donarb
About a week ago I was on a web page (which I can't find now) that had
some tricky javascript. I remember that some of the top-level object
definitions were surrounded by braces, I assume they were closures, but
I can't find any information online about this particular syntax. It
reminds me of something in Damien Conway's OO Perl book, what he calls
a shared lexical. Is it a closure and what would the benefit be?
This is a sample of what I recall it looked like:
{
function myObject() {}
myObject.prototype.dosomething = function() {}
myObject.prototype.dosomethingelse = function() {}
}
some tricky javascript. I remember that some of the top-level object
definitions were surrounded by braces, I assume they were closures, but
I can't find any information online about this particular syntax. It
reminds me of something in Damien Conway's OO Perl book, what he calls
a shared lexical. Is it a closure and what would the benefit be?
This is a sample of what I recall it looked like:
{
function myObject() {}
myObject.prototype.dosomething = function() {}
myObject.prototype.dosomethingelse = function() {}
}