Playing Around with Javascript

I recently started playing around with Javascript a bit more. I've used it for a lot of the more common tasks in the past: hiding/showing layers, rollovers, popups, and so on. Now I'm starting to look at the language and object model in more depth.

There are some interesting surprises. In Javascript, objects appear to be nothing more than a series of key/value pairs. Methods are achieved by assigning a function as a value to a key (ala function pointers).

There's a distinct "string" primitive type, but there's also a string wrapper object that is dynamically swapped in when necessary, such as myString.length. There is a distinct number type, but there is no separation between integer and float. The number type also appears to have a wrapper. The event model seems to be split between W3C standards and IE.

Overall, it's a interesting language. It tries to do the right thing by default, but provides you deeper options if you so choose.
Design Element
Playing Around with Javascript
Posted Apr 7, 2005 — 10 comments below




 

Java Buns — Apr 07, 05 121

What reference are you using, out of curiousity? I want to find a good JavaScript book...

Scott Stevenson — Apr 07, 05 124 Scotty the Leopard

You know, it's funny. I actually choose the O'Reilly Definitive Guide, thinking it was the most up-to-date with Javascript 1.5, but I now see that it was actually published in 2001.

I also was looking for the Peachpit/QuickStart title, and might have realized it was newer (2003), if I had been able to actually find it in Borders.

The O'Reilly title seems quite complete (around 800 pages), but the writing is pretty dry.

Scott Stevenson — Apr 07, 05 127 Scotty the Leopard

FWIW: The site says 2001, the book itself says 2002.

Erik Hanson — Apr 08, 05 129

See jsunit if you're interested in writing your Javascript test-first.

stephen rouse — Apr 10, 05 133

I've always found javascript to be a problematic language to debug. Have you discovered any useful tools/techniques?

Scott Stevenson — Apr 10, 05 134 Scotty the Leopard

It seems that this book suggests using document.write() or alert(). This page on Macslash has some interesting suggestions too. It says that Safari has a "Log Javascript Exceptions" option in the Debug menu.

stephen rouse — Apr 10, 05 135

Hmm... that Debug menu is pretty nifty. I notice it also gives you an outline view of the DOM Tree of a page. It would be cool if you could somehow debug javascript in xcode as it executes in the context of an embedded WebView, but i have no idea whether something like that is even possible given the technologies involved.

stephen rouse — Apr 11, 05 136

Hmm... that Debug menu is pretty nifty. I notice it also gives you an outline view of the DOM Tree of a page. It would be cool if you could somehow debug javascript in xcode as it executes in the context of an embedded WebView, but i have no idea whether something like that is even possible given the technologies involved.

Erik Hanson — Apr 12, 05 137

Mozilla has a Javascript debugger called Venkman. However, if you write your Javascript test-first with jsunit, you won't have to use the debugger much, or at all. (Really.)

Jason Short — May 20, 05 166

I use Javascript in Flash (AS2) and you can do some fantastic OO work with it. It even includes types to help with debugging. I wish Apple would implement JS instead of Applescript for things like Automator. Applescript is to obscure and counter intuitive to web developers and Flash coders who know JS, but don't know C well or Obj-C. It's a huge case of not invented here and a missed opportunity. Hopefully they learn from Dashboard Widgets...




 

Comments Temporarily Disabled

I had to temporarily disable comments due to spam. I'll re-enable them soon.





Copyright © Scott Stevenson 2004-2015