On 2010-08-29 14:32, booksort wrote:
@Garrett
Thanks. I know it's a mistake - just one that is easy to make if
you're working in JS and PHP at the same time.
@John
In this particular case, I typed
var hl = '<div id="csid' . puid . '"><h2 class="csclce">Searching for
extra information...</h2></div>';
instead of
var hl = '<div id="csid' + puid + '"><h2 class="csclce">Searching for
extra information...</h2></div>';
I was building some HTML, which I might just as easily be doing in
either language. It's the sort of error you can easily stare at but
not see.
JavaScript often just seems to stop running a script after this sort
of error. A page might load with no apparent errors. Then perhaps an
onclick event is fired, and something will be undefined because the
original script did not complete. The 'undefined' error will probably
be nowhere near the typo.
Is it possible for a syntax checker to flag something like this before
the code is actually run?
I suggest you use some kind of lint program to check common mistakes
like that. It will also help you spot other things that are not errors
but good programming recommendations.
http://www.jslint.com/ is one example. It's quite pedantic about the
errors it finds, however.
I use a modified version of jslint here on my own code, I integrated
jslint into my text editor "external tools" for ease of use.
This saves me from hours of silly syntax errors debugging, and forces me
to use a very good writing style, for instance forcing me to use
brackets on 1-statement IFs.
Nicolas
--
You received this message because you are subscribed to the Google Groups
"Firebug" 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/firebug?hl=en.