Allow me to highlight some recent articles for your reading pleasure.
Over at Digital Web magazine, they’ve gone JavaScript crazy. Last week, Mike West wrote an article all about Scope in JavaScript:
This article will tackle the problem head-on, outlining definitions of context and scope, examining two JavaScript methods that allow us to manipulate context, and concluding with a deep dive into an effective solution to ninety percent of the problems I’ve run into.
It’s fairly heavy going, but that’s the nature of the beast. Just as it’s hard to follow what this
refers to in your scripts, an explanation of the twists and turns of variable scope is bound to be a brainteaser. It’s not light reading but it’s well worth sticking with it to get that “A-ha!” moment.
More recently, Jonathan Snook wrote Objectifying JavaScript for the same magazine. This will be especially useful if JavaScript is your first programming language. The concept of objects is often very familiar to programmers of other languages, but it can be bewildering and intimidating to someone with a background in say, HTML and CSS.
Jonathan has written a clear article, but once again, the nature of the subject matter means that you’ll have to put some effort in to meet it halfway. It’s worth it. In fact, I’d suggest reading Jonathan’s article first and Mike’s article second. When you think about it, both articles deal with the subject of scope in JavaScript.
For a more relaxed read, delve into the code that Roger Johansson has written for creating Automatic pullquotes with JavaScript and CSS. It’s a great little straightforward script that’s been well thought out. He’s generating markup using the DOM, but the content of the markup is already contained in the document:
Using JavaScript for this is fine to me since the pullquotes serve mostly as scannability aids and design elements. The text exists in the markup, so users with JavaScript off aren’t missing out on any actual content.
Nicely done. There’s some good feedback in the comments too.
Posted by Jeremy on Thursday, September 21st, 2006 at 2:00pm
Sorry. Comments are closed.