Primary Navigation

Re: Undefined variable

... Is execution not an indication of use? I would think if something were properly executed it is used code by the interpreter even if that usage, or any

Message 1 of 25
, Jun 1, 2009

0 Attachment

> Ah. And now try the same thing, except do an 'alert(d)' in the last
> line. See what I mean? Both (function)s are executed, of course, but
> that's not the point. The point is that the *variables* d and z are
> never used.

Is execution not an indication of use? I would think if something were properly executed it is used code by the interpreter even if that usage, or any other usage, does not result in any restatement for execution in remaining logic.

Furthermore when function d from the example is alerted it returns undefined only because it returns nothing after it executes. This is equivalent to declaring a variable and not defining it. If a return and a quoted string are placed between the end of d and z then d alerts as a value. This is no indication that d is unused.

sandyhead25

... When I execute the program I am presented with a first alert displaying 9 and then a second alert displaying 6 . If I remove z from the program the

Message 2 of 25
, Jun 1, 2009

0 Attachment

> Variable z is in fact unused. The proof of that is that you can
> delete "var z = " from that program and the result will be exactly
> the same.
>

When I execute the program I am presented with a first alert displaying "9" and then a second alert displaying "6". If I remove z from the program the first alert will no longer be present, which is an alteration to the resultant execution even if all other code cannot see or feel that alteration.

This lack of connection implies that functions of immediate invocation contained as instantiation declarations within other objects have a special unique context until such functions are any way restated or reused outside their declaration. That special unique context would be largely meaningless if not for objects that contain closures and several immediate invocation functions as declarations using those closures after the closure variables are declared.

Your message has been successfully submitted and would be delivered to recipients shortly.