On 1/6/11, Mathias Bynens <math...@qiwi.be> wrote:
> You’re in the global scope, and you want to create a new global var.
> There are different options. What is the difference between them?
>
> 1) This will work because the current scope happens to be the global
> scope:
>
>     var foo = 42;
>

Use that to avoid errors in IE.

> Obviously, this would fail to create the var in the global scope when
> called from inside another scope.

You could add a property to global object; passed in, if needed.

See also:
http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.javascript/2009-09/msg00605.html

Garrett

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to