John Resig schrieb:
> Todd -
>
> You're correct, it's used to induce a contained scope.
>
> This was a technique that, if I remember correctly, I learned from
> Dean Edwards (http://dean.edwards.name/) I use to use:
>
> (function(){
> ...
> })();
>
> but new function() { ... }; is much cleaner, IMO. As far as I know,
> that is the "best" way to have a local scope, at least until
> JavaScript 2.0 comes out and you can do:
>
> let( foo = 'bar' ) {
> // ... do stuff with 'foo'
> }
> // foo doesn't exist out here
>
> --John
John, I think there is one difference between both techniques.
While in
new function() {
}
the this keyword points the "anonymous" object itself, in
(function() {
...
})();
it does not. Right?
-- Klaus
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/