<?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: How to make a singleton in javascript</title>
	<atom:link href="http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-make-a-singleton</link>
	<description>helping you with javascript since 2007</description>
	<lastBuildDate>Tue, 31 Jan 2012 11:22:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: NFL picks against the spread</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-1389</link>
		<dc:creator>NFL picks against the spread</dc:creator>
		<pubDate>Thu, 13 Oct 2011 12:21:43 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-1389</guid>
		<description>&lt;strong&gt;2011...&lt;/strong&gt;

I do agree with all the ideas you&#039;ve presented in your post. They are very convincing and will certainly work. Still, the posts are too short for beginners. Could you please extend them a little from next time? Thanks for the post....</description>
		<content:encoded><![CDATA[<p><strong>2011&#8230;</strong></p>
<p>I do agree with all the ideas you&#8217;ve presented in your post. They are very convincing and will certainly work. Still, the posts are too short for beginners. Could you please extend them a little from next time? Thanks for the post&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dYcxcgcvfgg</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-1320</link>
		<dc:creator>dYcxcgcvfgg</dc:creator>
		<pubDate>Sun, 09 Oct 2011 03:25:11 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-1320</guid>
		<description>&lt;strong&gt;2011...&lt;/strong&gt;

It’s really a nice and useful piece of info. I’m glad that you shared this helpful info with us. Please keep us up to date like this. Thanks for sharing....</description>
		<content:encoded><![CDATA[<p><strong>2011&#8230;</strong></p>
<p>It’s really a nice and useful piece of info. I’m glad that you shared this helpful info with us. Please keep us up to date like this. Thanks for sharing&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dYcxcgcvf</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-1285</link>
		<dc:creator>dYcxcgcvf</dc:creator>
		<pubDate>Sat, 08 Oct 2011 02:07:31 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-1285</guid>
		<description>&lt;strong&gt;2011...&lt;/strong&gt;

It’s really a great and helpful piece of info. I’m glad that you shared this helpful info with us. Please keep us informed like this. Thanks for sharing....</description>
		<content:encoded><![CDATA[<p><strong>2011&#8230;</strong></p>
<p>It’s really a great and helpful piece of info. I’m glad that you shared this helpful info with us. Please keep us informed like this. Thanks for sharing&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cool New Gadgets</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-1113</link>
		<dc:creator>Cool New Gadgets</dc:creator>
		<pubDate>Tue, 15 Mar 2011 19:57:32 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-1113</guid>
		<description>Ahh,, just following your instruction.. hope to implement it right away.</description>
		<content:encoded><![CDATA[<p>Ahh,, just following your instruction.. hope to implement it right away.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: josh09</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-850</link>
		<dc:creator>josh09</dc:creator>
		<pubDate>Sun, 29 Nov 2009 03:04:09 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-850</guid>
		<description>great lesson, I needed it</description>
		<content:encoded><![CDATA[<p>great lesson, I needed it</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to write a singleton class in javascript &#124; Javascript Kata</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-796</link>
		<dc:creator>How to write a singleton class in javascript &#124; Javascript Kata</dc:creator>
		<pubDate>Wed, 30 Sep 2009 12:59:57 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-796</guid>
		<description>[...] I look at my stats, a lot of people are wondering how to write a singleton class. I already wrote about it before but my old solution exposed the instance of the class so more than one instance could be created [...]</description>
		<content:encoded><![CDATA[<p>[...] I look at my stats, a lot of people are wondering how to write a singleton class. I already wrote about it before but my old solution exposed the instance of the class so more than one instance could be created [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-736</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Fri, 10 Apr 2009 16:04:57 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-736</guid>
		<description>Hi! I&#039;ve read all your posts and I&#039;m very glad of this discussion. I wonna give something back to all readers and posters in describing a small scenario, where singleton is more than just OOP-Global, and wonna show you, why I think that choosing the right singleton implementation is very important.

I&#039;m deloping a huge project including a JS-Framework. Therefore it&#039;s necessary to inherit classes. So imagine the following example:

We have a class Container and a inherited class FullFadeWindow. The Container-Class represents a Container-Widget that can be instantiated many times and that can contain data loaded per AJAX. The FullFadeWindow is a special window: its always on top and its covering the full screen (or browser window). So I want FullFadeWindow to be a singleton class, inheriting from Container, that is no singleton class.

This can&#039;t be done using a pure static implementation (like Dan&#039;s Log-Example), because of the prototype inheritance. Also the closures-solutions cannot be used this way, because all functions need to be declared in a local context which make prototype inheritance impossible. And because I cannot guarantee that nobody calls my constructor, if I&#039;m using Dan&#039;s first idea, the remaining possibility is MadKat&#039;s one above. This way, we can simple make an existing class to a singleton one, we can use prototype inheritance, and we do not need to &quot;milk&quot; JS to brutally make this object based language to an complete object oriented one.

In addition, the way described in http://kaijaeger.com/articles/the-singleton-design-pattern-in-javascript.html (posted by Antony above) is also not usable in this scenario.

So, if you plan to use prototype inheritance (you know, like X.prototype = new Y()), you should consider MadKat&#039;s solution.

Have fun,
   Phil</description>
		<content:encoded><![CDATA[<p>Hi! I&#8217;ve read all your posts and I&#8217;m very glad of this discussion. I wonna give something back to all readers and posters in describing a small scenario, where singleton is more than just OOP-Global, and wonna show you, why I think that choosing the right singleton implementation is very important.</p>
<p>I&#8217;m deloping a huge project including a JS-Framework. Therefore it&#8217;s necessary to inherit classes. So imagine the following example:</p>
<p>We have a class Container and a inherited class FullFadeWindow. The Container-Class represents a Container-Widget that can be instantiated many times and that can contain data loaded per AJAX. The FullFadeWindow is a special window: its always on top and its covering the full screen (or browser window). So I want FullFadeWindow to be a singleton class, inheriting from Container, that is no singleton class.</p>
<p>This can&#8217;t be done using a pure static implementation (like Dan&#8217;s Log-Example), because of the prototype inheritance. Also the closures-solutions cannot be used this way, because all functions need to be declared in a local context which make prototype inheritance impossible. And because I cannot guarantee that nobody calls my constructor, if I&#8217;m using Dan&#8217;s first idea, the remaining possibility is MadKat&#8217;s one above. This way, we can simple make an existing class to a singleton one, we can use prototype inheritance, and we do not need to &#8220;milk&#8221; JS to brutally make this object based language to an complete object oriented one.</p>
<p>In addition, the way described in <a href="http://kaijaeger.com/articles/the-singleton-design-pattern-in-javascript.html" rel="nofollow">http://kaijaeger.com/articles/the-singleton-design-pattern-in-javascript.html</a> (posted by Antony above) is also not usable in this scenario.</p>
<p>So, if you plan to use prototype inheritance (you know, like X.prototype = new Y()), you should consider MadKat&#8217;s solution.</p>
<p>Have fun,<br />
   Phil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antony S</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-725</link>
		<dc:creator>Antony S</dc:creator>
		<pubDate>Fri, 13 Mar 2009 05:28:04 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-725</guid>
		<description>A very good and simple article on singleton in JS.

http://kaijaeger.com/articles/the-singleton-design-pattern-in-javascript.html</description>
		<content:encoded><![CDATA[<p>A very good and simple article on singleton in JS.</p>
<p><a href="http://kaijaeger.com/articles/the-singleton-design-pattern-in-javascript.html" rel="nofollow">http://kaijaeger.com/articles/the-singleton-design-pattern-in-javascript.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-718</link>
		<dc:creator>Dan</dc:creator>
		<pubDate>Sun, 22 Feb 2009 18:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-718</guid>
		<description>@zoips @jb
I really like your alternatives. I&#039;ll write a new article with that. Thanks a lot.</description>
		<content:encoded><![CDATA[<p>@zoips @jb<br />
I really like your alternatives. I&#8217;ll write a new article with that. Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jb</title>
		<link>http://www.javascriptkata.com/2007/04/04/how-to-make-a-singleton/comment-page-1/#comment-717</link>
		<dc:creator>jb</dc:creator>
		<pubDate>Sun, 22 Feb 2009 17:54:58 +0000</pubDate>
		<guid isPermaLink="false">http://javascriptkata.timmyontime.com/?p=21#comment-717</guid>
		<description>well a very simple way of having singleton is this
Test= function(){
      if(!Test.prototype.instance)
          Test.prototype.instance=this;
       else
	  return Test.prototype.instance;
}

^^</description>
		<content:encoded><![CDATA[<p>well a very simple way of having singleton is this<br />
Test= function(){<br />
      if(!Test.prototype.instance)<br />
          Test.prototype.instance=this;<br />
       else<br />
	  return Test.prototype.instance;<br />
}</p>
<p>^^</p>
]]></content:encoded>
	</item>
</channel>
</rss>

