Thanks for the explanation and links! Anton
On Wednesday, April 20, 2011 at 2:13 AM, Lasse Reichstein wrote: > On Wed, 20 Apr 2011 04:09:02 +0200, Angus Croll <[email protected]> > wrote: > > > We can prove it like this: > > > > > > function outer() { > > var a = true; > > > > return function(expr) { > > eval(expr) > > } > > } > > > > //get inner function > > var inner = outer(); > > > > //ask inner function for value of a - even though it was not in the inner > > function definition > > inner("console.log(a)"); //true > > > That's one of th reasons eval makes code slower. Anywhere an eval can > happen, > all closures it's contained in must retain all visible variables. > > If the eval had not been there, but just an expression that didn't use "a", > then it's possible to make a closure that can't access the "a" variable - > because > it's known at compile time that it never will. > > /L > -- > Lasse Reichstein Holst Nielsen - [email protected] > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
