Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------------------------------------------------
- // your-company.js
- window.yourCompany = {
- version: '1.0',
- namespace: function(path) {
- var part,
- currentObject = window,
- parts = path.split('.')
- ;
- for (var i=0, len=parts.length; i < len; i++) {
- part = parts[i];
- if (!currentObject.hasOwnProperty(part)) {
- currentObject[part] = {};
- }
- currentObject = currentObject[part];
- }
- return currentObject;
- }
- };
- //-------------------------------------------------------------
- // your-company/ui/wizzle.js
- (function() {
- var ns = yourCompany.namespace('yourCompany.ui.wizzle');
- ns.defaultSize = 'tall';
- })();
- //-------------------------------------------------------------
- // Console
- console.log(yourCompany.version); // -> 1.0
- console.log(yourCompany.ui.wizzle.defaultSize); // -> tall
- console.log(window.ns); // -> undefined
Add Comment
Please, Sign In to add comment