Skip to content

Instantly share code, notes, and snippets.

@roundcorners
roundcorners / namespace-check.js
Created February 1, 2012 18:24
Checking properties before assignment
// These checks ensure the namespace is only created if it doesn't already exist.
var myNamespace = myNamespace || {},
// A check is required for each subsequent property of the namespace
application = myNamespace.application || {},
myFunc = myNamespace.application.anotherProperty.myFunc || function () {
// function definition...
};