[Proto-Scripty] Re: Prototype/Javascript scoping question

2009-05-17 Thread T.J. Crowder
> Right, I was assuming correct syntax for #1 (my bad): As I said, I was assuming he was doing more than just this.bar(). -- T.J. On May 17, 9:58 pm, Tobie Langel wrote: > > Isn't closure formed in both #1 and #2 as soon as FunExpr. (passed to > > `each`) is being evaluated? > > Right, I was a

[Proto-Scripty] Re: Prototype/Javascript scoping question

2009-05-17 Thread Tobie Langel
> Isn't closure formed in both #1 and #2 as soon as FunExpr. (passed to > `each`) is being evaluated? Right, I was assuming correct syntax for #1 (my bad): $R(1,2).each(this.bar, this); which avoids the extra closure altogether. --~--~-~--~~~---~--~~ You recei

[Proto-Scripty] Re: Prototype/Javascript scoping question

2009-05-17 Thread kangax
On May 16, 12:51 pm, Tobie Langel wrote: > FYI, fastest way is #1 as you're avoiding creating a closure > altogether (just using Function#call internally). Isn't closure formed in both #1 and #2 as soon as FunExpr. (passed to `each`) is being evaluated? [...] -- kangax --~--~-~--~~

[Proto-Scripty] Re: Prototype/Javascript scoping question

2009-05-16 Thread Tobie Langel
FYI, fastest way is #1 as you're avoiding creating a closure altogether (just using Function#call internally). On May 16, 10:35 am, "T.J. Crowder" wrote: > Hi, > > I don't know that there's any one standard pattern, but here are a > couple of the more common ones [here I'm assuming that the clos

[Proto-Scripty] Re: Prototype/Javascript scoping question

2009-05-16 Thread T.J. Crowder
Hi, I don't know that there's any one standard pattern, but here are a couple of the more common ones [here I'm assuming that the closure will actually do more than just this.bar()]: 1. Specifically when using Enumerable#each[1], it has this handy second parameter you can use to set the context