[jQuery] Re: vars in unnamed functions

2007-04-18 Thread Evan
ly on this behavior in javascript? > > - Original Message > From: Rob Desbois <[EMAIL PROTECTED]> > To: jquery-en@googlegroups.com > Sent: Wednesday, April 18, 2007 1:52:21 AM > Subject: [jQuery] Re: vars in unnamed functions > > 17By creating a function form yo

[jQuery] Re: vars in unnamed functions

2007-04-18 Thread Ariel Jakobovits
so is it ok to rely on this behavior in javascript? - Original Message From: Rob Desbois <[EMAIL PROTECTED]> To: jquery-en@googlegroups.com Sent: Wednesday, April 18, 2007 1:52:21 AM Subject: [jQuery] Re: vars in unnamed functions 17By creating a function form your code whic

[jQuery] Re: vars in unnamed functions

2007-04-18 Thread Ben Schwarz
I found the concept of closures confusing after reading articles that I discovered with google. However you should be able to recognise that your var keyword variables inside your init method are vars of that method.. they do not exist within the window object (window being the top most level). O

[jQuery] Re: vars in unnamed functions

2007-04-18 Thread Kenneth
I just read the Wikipedia article on closures[1] today and learned quite a bit myself (which isn't saying much!). I would recommend it to anyone wanting to learn more about it. To quote a portion: "[...] a closure is a semantic concept referring to a function paired with an environment [...] Typi

[jQuery] Re: vars in unnamed functions

2007-04-18 Thread Rob Desbois
17By creating a function form your code which uses variables outside its scope, you've created a 'closure'. When settings.functionToCallLater() is called after init() has finished, aVariable has gone out of scope. The function still has access to it however, because the closure consists of two pa