O'Reilly logo

Learning JavaScript by Shelley Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Your Own Custom JavaScript Objects

In the last few chapters of the book, which cover Ajax and the various code libraries you can download, you’ll see how much improvisation was used to create objects using JavaScript. At times, these libraries look almost as if they’re built in a language other than JS. In fact, many were built specifically to overlay the JavaScript language with other language characteristics, which has both advantages and disadvantages.

An advantage is that the library provides shortcuts for some of the more tedious operations, such as accessing page elements. Laying another language’s flavor over JS may also make it easier if you use this language as the server-side component in an Ajax application.

The disadvantage is that this effort obfuscates the underlying JavaScript, making the library hard to read, hard to use, and confusing if you’re not necessarily up on all the latest language advances.

One of the best essays I’ve seen written on the ambivalence associated with some of the clever and powerful, but obscuring, component libraries is “Painless JavaScript Using Prototype” by Dan Webb at Sitepoint (at http://www.sitepoint.com/article/painless-javascript-prototype).

Tip

JavaScript-library developers just can’t seem to keep from trying to make JavaScript act like another language. The Mochikit guys want JavaScript to be Python, countless programmers have tried to make JavaScript like Java, and Prototype tries to make it like Ruby. Prototype makes extensions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required