News for hackers. Stuff that matters.
Re:Advanced JavaScript Techniques by nkohari on Friday October 09, 2009 @01:21PM (#871940)
I use this function to create namespaces:

  var namespace = function(ns) {
    var scope = window;
    var tokens = ns.split(".");
    for (var idx = 0, len = tokens.length; idx < len; idx++) {
      var token = tokens[idx];
      scope = scope[token] = scope[token] || {};
    }
  };
For example: namespace("Zen.Ui");
Re:Advanced JavaScript Techniques by woadwarrior01 on Friday October 09, 2009 @06:20PM (#872584)
YAHOO.namespace in YUI does the same thing, except that it creates everything under the YAHOO namespace.
Re:Advanced JavaScript Techniques by yannis on Friday October 09, 2009 @03:15PM (#872235)
Clever! How do you add your properties and methods? Another clever trick?