On 4/20/07, Jim Davis <[EMAIL PROTECTED]> wrote:
> >Hey all,
> >
> >I've got two javascript functions in a .js template.
> >
> >If I set a var in the first function, can I use it in the second function?
>
> It depends on whether or not you scope it locally.
>
> The "var" keyword tells a variable "you're only available in the current or 
> child scopes".  Without the key word the variable will be global and 
> available to anything.
>
> For example:
>
> function MyFunc1() {
>    var foo = 1;  // I'm a local var!
>    faa = 1; // I'm a global var!
> };

Very cool.  I didn't realize the var keyword actually "did" anything.
I thought it was somewhat of a formality in JS (not unlike terminating
a line with a semi-colon being optional).

I had thought any variable created inside of a function (regardless of
whether or not var'd) would be local to only that function.

-- 
Charlie Griefer

================================================
"...All the world shall be your enemy, Prince with a Thousand Enemies,
and whenever they catch you, they will kill you. But first they must catch
you, digger, listener, runner, prince with a swift warning.
Be cunning and full of tricks and your people shall never be destroyed."

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Deploy Web Applications Quickly across the enterprise with ColdFusion MX7 & 
Flex 2
Free Trial 
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJU

Archive: 
http://www.houseoffusion.com/groups/CF-Community/message.cfm/messageid:233135
Subscription: http://www.houseoffusion.com/groups/CF-Community/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5

Reply via email to