|
|
 |
RE: FN-FORUM: Javascript help....
date posted 7th August 2003 23:12
> ========================
> Wednesday 6th August 2003 17:30:47
> RE: FN-FORUM: JavaScript help.... - Ross Hamilton [EMAIL REMOVED]
> This prevents you from doing stuff like:
>
> if ie4 do stuff
>
> If we stuck to your suggestion we'd have to do something like
> this instead:
>
> if !navigator && version == 4 do stuff
>
> I know which I'd prefer. So what if you're declaring more
> variables than you strictly need? It's not as if your
> computer is going to have trouble keeping track of six
> variables instead of two!
I'm with Ross. You're storing intermediate values, which in my view
often makes life easier for the programmer (the computer can work it out
and, in compiled languages at least, will tend to produce the same
optimised code each way). Of course you have to be careful with
lifecycles and state changes, etc. (but browsers are unlikely to change
their type in mid-request!)
Of course, the *proper* way to do things would be to have a method:
function IsIE4() { return !navigator && version==4 }
But if you understand it, your computer can understand it and it does
what you expect, then it's probably good enough for websites!
One of the irritating things about SQL is that it doesn't take kindly to
this sort of thinking, and you have to be logically correct when
designing databases and writing queries.
Just my NZD0.03,
Richard
|
 |
|