[Home]

JavaScript

In late 2005 I started trying to learn javascript... after several years of messing around with Java I found javascript to be more comfortable, coming from a Perl background. I took an online class with netglearning which was near useless and the test had bogus questions on it. What I found was that the basics of the language was pretty easy. The DOM was the tricky part, and I was used to languages with symbolic debuggers and more traditional command line interfaces (i.e. you can always add debugging printfs). I finally started to get it once Firebug came out!

Best Practices

In my reading, it seems like most writings about javascript focus on technical details, often specific to a certain browser. There seems to be a distinct lack of resources about how to write good code.

Exception Handling

There is little written about this beyond the basic mechanics of try, catch and throw. Despite seeing a lot of code which does a throw with a string it seems that a new Error() object should be created. These objects seem to variate amongst browsers.
Error()
IE 6Firefox 1.5
name Error Error
number 0  
description blank  
message blank blank
fileName   name of file
lineNumber  line number
stack   text representing a stack trace
Error(msg1)
IE 6Firefox 1.5
name Error Error
number   
description msg1  
message msg1 msg1
fileName   name of file
lineNumber  line number
stack   text representing a stack trace
Error(msg1, msg2)
IE 6Firefox 1.5
name Error Error
number Number(msg1)  
description msg2  
message msg2 msg1
fileName   msg2
lineNumber  line number
stack   text representing a stack trace
Error(msg1, msg2, msg3)
IE 6Firefox 1.5
name Error Error
number Number(msg1)  
description msg2  
message msg2 msg1
fileName   msg2
lineNumber  Number(msg3)
stack   text representing a stack trace

See also: [ECMA 262 Standard]

Resources

Things of Interest



VeganMilitia | RecentChanges | What links here | Preferences | Upload | Page List
This page is read-only | View other revisions
Last edited April 20, 2007 11:27 am by inet-netcache3-o.oracle.com (diff)
Search: SearchHelp
Powered by Laughing Squid