JavaScript: Difference between revisions

Content deleted Content added
Func (talk | contribs)
m Reverted edits by 203.199.202.97 to last version by Tobias Bergemann
Hirzel (talk | contribs)
[[Error handling]]: Finding errors while developing is not a property of the language, but of the development environment. Nowadays the situation is better.
Line 333:
 
===[[Error handling]]===
JavaScriptDepending hason acquiredthe adevelopment notoriousenvironment reputationdebugging amongused programmers for its idiosyncratic methodto ofbe error handlingdifficult. Since errors in JavaScript only appear in run-time (i.e., there is no way to check for errors without executing the code), and since JavaScript is interpreted by the web browser as the page is viewed, it ismay extremelybe difficult to track the cause for JavaScripterrors. toHowever generatenowadays the [[Gecko]]-based browsers come with a usefulfairly errorgood message.[[debugger]] Someand actuala examples:[[DOM]] inspector.
 
<code>Error: Object expected. Line: unknown.</code> (this is comparatively helpful)
<code>Error: Unknown Syntax Error. Line: 1.</code> (there were no problems on line 1)
<code>Error: ||| Line: unknown. </code> (really!)
 
In addition, simple errors in syntax tend to generate complex, unrelated error messages, so that deciphering a simple misplaced quotation mark can require many executions and tests to find the correct place.
Newer versions of JavaScript (as used in [[Internet Explorer]] 5 and [[Netscape (web browser)|Netscape]] 6) include a <tt>try ... catch</tt> error handling statement. Purloined from the [[Java_programming_language]], this is intended to help with run-time errors but does so with mixed results.