<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: An Easy Way to Implement Namespaces in JavaScript</title>
	<atom:link href="http://blog.arc90.com/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.arc90.com/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/</link>
	<description>Web Application Design &#38; Development</description>
	<lastBuildDate>Thu, 29 Jul 2010 10:34:30 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Timothy Stone</title>
		<link>http://blog.arc90.com/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-688</link>
		<dc:creator>Timothy Stone</dc:creator>
		<pubDate>Fri, 31 Jul 2009 16:41:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.daniell.acr90-dev-02/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-688</guid>
		<description>Hmmm... concerned about that use of `eval&#039; ... you might want to consider refactoring it. Take a look at the YAHOO object itself for an example with leveraging `eval&#039;.</description>
		<content:encoded><![CDATA[<p>Hmmm&#8230; concerned about that use of `eval&#8217; &#8230; you might want to consider refactoring it. Take a look at the YAHOO object itself for an example with leveraging `eval&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Melman</title>
		<link>http://blog.arc90.com/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-687</link>
		<dc:creator>Alex Melman</dc:creator>
		<pubDate>Thu, 07 Aug 2008 17:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.daniell.acr90-dev-02/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-687</guid>
		<description>Thanks for the comments.  To Mazharkhan, I actually do have an example of how to use the function, but I realize that I sort of buried it in the middle.  Basically, you use the function as such:
createNamespace(&quot;arc90.components&quot;);
This creates the namespace, so now you can define functions and classes such as:
arc90.components.CheckBox = {};
The advantage of using the function is that if you don&#039;t, you will have to define each level of the namespace separately, like this:
var arc90 = {};
var arc90.components = {};
In addition, you would have to check to see if those objects already exist.  Otherwise you will overwrite them with blank objects, which is not what you want to do when defining a namespace.
As for the first comment, I promise to address it soon.</description>
		<content:encoded><![CDATA[<p>Thanks for the comments.  To Mazharkhan, I actually do have an example of how to use the function, but I realize that I sort of buried it in the middle.  Basically, you use the function as such:<br />
createNamespace(&#8220;arc90.components&#8221;);<br />
This creates the namespace, so now you can define functions and classes such as:<br />
arc90.components.CheckBox = {};<br />
The advantage of using the function is that if you don&#8217;t, you will have to define each level of the namespace separately, like this:<br />
var arc90 = {};<br />
var arc90.components = {};<br />
In addition, you would have to check to see if those objects already exist.  Otherwise you will overwrite them with blank objects, which is not what you want to do when defining a namespace.<br />
As for the first comment, I promise to address it soon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mazharkhan</title>
		<link>http://blog.arc90.com/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-686</link>
		<dc:creator>Mazharkhan</dc:creator>
		<pubDate>Thu, 07 Aug 2008 16:56:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.daniell.acr90-dev-02/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-686</guid>
		<description>I got something and something not.
you give only 50% guidance. if you put one example with every blog.</description>
		<content:encoded><![CDATA[<p>I got something and something not.<br />
you give only 50% guidance. if you put one example with every blog.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh W</title>
		<link>http://blog.arc90.com/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-685</link>
		<dc:creator>Josh W</dc:creator>
		<pubDate>Thu, 03 Jul 2008 02:43:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.daniell.acr90-dev-02/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-685</guid>
		<description>// Let&#039;s try that &quot;for&quot; again.
function createNamespace(ns)
{
// First split the namespace string separating each level of the namespace object.
var splitNs = ns.split(&quot;.&quot;);
// Define a string, which will hold the name of the object we are currently working with.  Initialize to the first part.
var builtNs = splitNs[0];
var i, base = window;
for (i = 0; i &lt; splitNs.length; i++)
{
if (typeof(base[ splitNs[i] ]) == &quot;undefined&quot;) base[ splitNs[i] ] = {};
base = base[ splitNs[i] ];
}
return base;    // Return the namespace as an object.
}</description>
		<content:encoded><![CDATA[<p>// Let&#8217;s try that &#8220;for&#8221; again.<br />
function createNamespace(ns)<br />
{<br />
// First split the namespace string separating each level of the namespace object.<br />
var splitNs = ns.split(&#8220;.&#8221;);<br />
// Define a string, which will hold the name of the object we are currently working with.  Initialize to the first part.<br />
var builtNs = splitNs[0];<br />
var i, base = window;<br />
for (i = 0; i &lt; splitNs.length; i++)<br />
{<br />
if (typeof(base[ splitNs[i] ]) == &#8220;undefined&#8221;) base[ splitNs[i] ] = {};<br />
base = base[ splitNs[i] ];<br />
}<br />
return base;    // Return the namespace as an object.<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh W</title>
		<link>http://blog.arc90.com/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-684</link>
		<dc:creator>Josh W</dc:creator>
		<pubDate>Thu, 03 Jul 2008 02:36:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.daniell.acr90-dev-02/2008/06/06/an-easy-way-to-implement-namespaces-in-javascript/#comment-684</guid>
		<description>You have a typo:
for (i = 0, i  0) ? (&quot;.&quot; + splitNs[i]) : &quot;&quot;;
// Check if the object we want to add exists, and add a new empty object if it doesnt.
eval(builtNs + &quot; = typeof(&quot; + builtNs + &quot;) ==&#039;undefined&#039; ? {} : &quot; + builtNs + &quot;; &quot;);
}
return eval(ns);    // Return the namespace as an object.
}
You also might be able to use &quot;window&quot; instead of &quot;eval&quot;, as eval can but unsafe.
function createNamespace(ns)
{
// First split the namespace string separating each level of the namespace object.
var splitNs = ns.split(&quot;.&quot;);
// Define a string, which will hold the name of the object we are currently working with.  Initialize to the first part to the current window.
var i, base = window;
for (i = 0; i</description>
		<content:encoded><![CDATA[<p>You have a typo:<br />
for (i = 0, i  0) ? (&#8220;.&#8221; + splitNs[i]) : &#8220;&#8221;;<br />
// Check if the object we want to add exists, and add a new empty object if it doesnt.<br />
eval(builtNs + &#8221; = typeof(&#8221; + builtNs + &#8220;) ==&#8217;undefined&#8217; ? {} : &#8221; + builtNs + &#8220;; &#8220;);<br />
}<br />
return eval(ns);    // Return the namespace as an object.<br />
}<br />
You also might be able to use &#8220;window&#8221; instead of &#8220;eval&#8221;, as eval can but unsafe.<br />
function createNamespace(ns)<br />
{<br />
// First split the namespace string separating each level of the namespace object.<br />
var splitNs = ns.split(&#8220;.&#8221;);<br />
// Define a string, which will hold the name of the object we are currently working with.  Initialize to the first part to the current window.<br />
var i, base = window;<br />
for (i = 0; i</p>
]]></content:encoded>
	</item>
</channel>
</rss>
