On Jan 8, 7:40 pm, Chrilith <[email protected]> wrote:
> Roger, I usuggest you to learn a bit more how javascript works.
I suggest you learn how to quote. Put your reply below the text
you're responding too, trim the bits you aren't. You removed the
line:
window.iui =
which is indeed poor form, though it is not a particularly severe
issue. It assumes a window object exists and can be extended, however
since iUI is written for browsers it's probably pretty harmless.
If the intention was to create a global variable, then:
var global = (function(){return this;})();
global.iui = ...
will do the job without fear of throwing an error in UAs that don't
have a window object.
>
> > This is a mistake. The window object is a host object, so it should
> > not be augmented. This also assumes that the global window property
> > references the Global Object. The proper way to do this is to store a
> > reference to the Global Object prior to entering the one-off function.
>
> Try this:
>
> var a = "test";
> alert(window.a);
>
> Oh, my god, I've expanded the window object!!!!
No you haven't, you've added a property to the global object.
Browsers have a window object which is synonymous with the global
object.
> As you said earlier
> yes, context is important in javascript (this is why there are apply
> and call methods which let us change the context),
"Context"? Presumably you mean execution context, the call and apply
methods set the value of a called function's this keyword, that's it.
They don't do anything with regard to the execution context of the
current function. But that has nothing to do with the issue being
discussed.
> and the default
> context here is "window" - so what's wrong with expando, could you
> argument on this?
You've completely missed the point, see above. There is no "window"
context, the execution context is the anonymous function that wraps
the rest of the code, it isn't global code. The authors are trying to
create a global variable, if it was global code they'd have written:
var iui = ...
(at least I hope so).
--
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---