O'Reilly logo

JavaScript Object Programming by Martin Rinehart

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

CHAPTER 6

image

More Ex Nihilo Objects

The more you write JavaScript, the more indispensable ex nihilo objects become. It seems that almost every senior JavaScript coder (senior by years of experience in JavaScript, not in life) uses ex nihilo objects as namespaces, which we’ll look at first. I claim a bit more originality for the idea of an ex nihilo class, our second example.

The Ex Nihilo Namespace Object

One of the most serious deficiencies of JavaScript is its lack of any namespace capability. It would be nice if my_code.js did not collide with your_code.js, but that requires some work on our part. The common solution is to create a namespace object ...

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