[thelist] javascript debug (easy)

Sam Foster sam at sam-i-am.com
Tue Jun 7 00:17:55 CDT 2005


my 2c

your tab indented statements and curly brace-wrapped blocks are 
invaluable for general code layout. But some simple conditionals tip the 
balance for me, and I'd rather use the tertiary operator than open yet 
another nested if.

Likewise with omitting braces for single statement "blocks". As a perl 
programmer I sorely miss the dothis unless(something) idiom. It flows 
much more like natural language and can (sometimes not always) greatly 
improve readability. The closest javascript will let us get is

if(!something) dothis;

.. which to my mind is an improvement (for such a simple statement) over

if(! something) {
    dothis;
}

I am a firm advocate of *always* ending statements with ';'

btw, the did the OP get an answer to the question? (before we hijacked 
this thread :)  I wondered if the target attribute would always cause 
the window to open, no matter what the return value of onclick.. but 
didn't test. Its worth pointing out also that the target attribute is 
deprecated, and targetting should now be a script operation.

Sam




More information about the thelist mailing list