Making stuff as a founder of Avocado. Former music-maker. Tuna melt advocate. Started Google Reader. (But smarter people made it great.)

What's In A Name? An Object Property.

This post about namespace collisions in Javascript at the Marius Weblog outlines, in part, a technique I've also been using for some time and which is a keeper, I think, for those of us writing large libraries in Javascript.

Large libraries with sensible naming conventions will find themselves somewhat hampered as unique function names that can be widely appropriate will get snatched up. In order to avoid namespace collision then, I (and Marius, it seems) will create a user-defined object that stores methods and element IDs.
function Posting() {}

Posting.SAVE_BUTTON_ID = "Save";

Posting.Save = function()
{
...code does something...
}
and so forth...
posted at July 21, 2004, 5:28 PM