<?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: Namespaced made easy with Prototype</title>
	<atom:link href="http://ajaxian.com/archives/namespaced-made-easy-with-prototype/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/namespaced-made-easy-with-prototype</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 17 May 2012 07:43:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: aemkei</title>
		<link>http://ajaxian.com/archives/namespaced-made-easy-with-prototype/comment-page-1#comment-261271</link>
		<dc:creator>aemkei</dc:creator>
		<pubDate>Mon, 11 Feb 2008 10:41:41 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3290#comment-261271</guid>
		<description>&lt;code&gt;
var Namespace = {
  separator: &quot;.&quot;,
  create: function(space){
    return space.split(
      Namespace.separator
    ).inject(
      window, function(parent, child) {
        return parent[child] = parent[child] &#124;&#124; {};
    })
  }
};

&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p><code><br />
var Namespace = {<br />
  separator: ".",<br />
  create: function(space){<br />
    return space.split(<br />
      Namespace.separator<br />
    ).inject(<br />
      window, function(parent, child) {<br />
        return parent[child] = parent[child] || {};<br />
    })<br />
  }<br />
};</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sentientholon</title>
		<link>http://ajaxian.com/archives/namespaced-made-easy-with-prototype/comment-page-1#comment-261179</link>
		<dc:creator>sentientholon</dc:creator>
		<pubDate>Thu, 07 Feb 2008 14:29:11 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3290#comment-261179</guid>
		<description>It&#039;s a great technique, but it SO doesn&#039;t belong in the String class!  Have a function like Namespace.create(&#039;foo.bar.baz.quux&#039;) that does the same thing and returns a reference to the innermost namespace created.</description>
		<content:encoded><![CDATA[<p>It&#8217;s a great technique, but it SO doesn&#8217;t belong in the String class!  Have a function like Namespace.create(&#8216;foo.bar.baz.quux&#8217;) that does the same thing and returns a reference to the innermost namespace created.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jdalton</title>
		<link>http://ajaxian.com/archives/namespaced-made-easy-with-prototype/comment-page-1#comment-261116</link>
		<dc:creator>jdalton</dc:creator>
		<pubDate>Mon, 04 Feb 2008 15:47:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3290#comment-261116</guid>
		<description>Alternately this version http://pastie.caboo.se/147291 allows for extending exisitng object namespaces as well as setting a custom separator.</description>
		<content:encoded><![CDATA[<p>Alternately this version <a href="http://pastie.caboo.se/147291" rel="nofollow">http://pastie.caboo.se/147291</a> allows for extending exisitng object namespaces as well as setting a custom separator.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jdalton</title>
		<link>http://ajaxian.com/archives/namespaced-made-easy-with-prototype/comment-page-1#comment-261114</link>
		<dc:creator>jdalton</dc:creator>
		<pubDate>Mon, 04 Feb 2008 15:05:42 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3290#comment-261114</guid>
		<description>Awesome snippet. I need to use inject() more often.
Here is a pastied cleaner version of the code fix for the bug Aemkei pointed out: http://pastie.caboo.se/147274</description>
		<content:encoded><![CDATA[<p>Awesome snippet. I need to use inject() more often.<br />
Here is a pastied cleaner version of the code fix for the bug Aemkei pointed out: <a href="http://pastie.caboo.se/147274" rel="nofollow">http://pastie.caboo.se/147274</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aemkei</title>
		<link>http://ajaxian.com/archives/namespaced-made-easy-with-prototype/comment-page-1#comment-261110</link>
		<dc:creator>aemkei</dc:creator>
		<pubDate>Mon, 04 Feb 2008 13:13:53 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3290#comment-261110</guid>
		<description>We should check if an object is already exist in our namespace chain.
This wont work:

&lt;code&gt;
&quot;foo.bar.baz&quot;.namespace();
&quot;foo.bar.bay&quot;.namespace();
console.log(foo.bar.baz);  // undefined
&lt;/code&gt;

Fixed code:

&lt;code&gt;
String.prototype.namespace = function(separator){
  this.split(separator &#124;&#124; &#039;.&#039;).inject(window, function(parent, child) {
    var o = parent[child] = parent[child] &#124;&#124; { }; return o;
  })
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>We should check if an object is already exist in our namespace chain.<br />
This wont work:</p>
<p><code><br />
"foo.bar.baz".namespace();<br />
"foo.bar.bay".namespace();<br />
console.log(foo.bar.baz);  // undefined<br />
</code></p>
<p>Fixed code:</p>
<p><code><br />
String.prototype.namespace = function(separator){<br />
  this.split(separator || '.').inject(window, function(parent, child) {<br />
    var o = parent[child] = parent[child] || { }; return o;<br />
  })<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: remy</title>
		<link>http://ajaxian.com/archives/namespaced-made-easy-with-prototype/comment-page-1#comment-261107</link>
		<dc:creator>remy</dc:creator>
		<pubDate>Mon, 04 Feb 2008 12:36:55 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3290#comment-261107</guid>
		<description>Doh - code got cut off:

&lt;code&gt;String.prototype.namespace = function(separator) {
    var ns = this.split(separator &#124;&#124; &#039;.&#039;), p = window;
    for (i = 0; i &lt; ns.length; i++) {
        p = p[ns[i]] = {};
    }
};&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Doh &#8211; code got cut off:</p>
<p><code>String.prototype.namespace = function(separator) {<br />
    var ns = this.split(separator || '.'), p = window;<br />
    for (i = 0; i &lt; ns.length; i++) {<br />
        p = p[ns[i]] = {};<br />
    }<br />
};</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: remy</title>
		<link>http://ajaxian.com/archives/namespaced-made-easy-with-prototype/comment-page-1#comment-261106</link>
		<dc:creator>remy</dc:creator>
		<pubDate>Mon, 04 Feb 2008 12:35:58 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=3290#comment-261106</guid>
		<description>Alternatively for those not using Prototype - since namespaces are definitely worth using:

&lt;code&gt;String.prototype.namespace = function(separator) {
    var ns = this.split(separator &#124;&#124; &#039;.&#039;), p = window;
    for (i = 0; i &lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Alternatively for those not using Prototype &#8211; since namespaces are definitely worth using:</p>
<p><code>String.prototype.namespace = function(separator) {<br />
    var ns = this.split(separator || '.'), p = window;<br />
    for (i = 0; i </code></p>
]]></content:encoded>
	</item>
</channel>
</rss>

