lol

ok

my understanding is, if you set a variable inside a function then you should
var it so that when the memory assigned to the function is disposed, the
variables are disposed with it.

Because you are setting a variable at the document level and not inside a
function you dont need to var it.

Basically when you var a variable it becomes scoped and is only accessible
from the function you have set it in.

Basically window and document are the same thing so when you set "var test;"
you are setting it to the scope of the document/window.  The thing is that
you have to be careful when you var stuff especially when you are using them
all over the place because of the scoping side of things.

I don't see the point in varing variables that are meant to be "global" type
variables as they are meant to be accessed everywhere anyway.  When someone
says "You should always declare variables with var. Always.", does this mean
you var your functions?

var myFunc;

function myFunc () {
        alert("from me")
        }

doubt it

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Michal
Sent: Friday, 19 December 2008 12:18 AM
To: MooTools Users
Subject: Re: IE(6) and variables in domready


Steve:
> dont "var" the variable

nutron:
> You should always declare variables with var. Always.

Now I definitely am confused! I am also confused by the apparent
differences (given by stratboy) between:

var mainMenu (when declared in global scope) and
window.mainMenu (declared in any scope)

I thought these were the same...? I've made a test seems to suggest
they are the same: http://paste.mootools.net/f8a0120c

Michal.

Reply via email to