<?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: Singletons in JavaScript</title>
	<atom:link href="http://www.ashita.org/singletons-in-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ashita.org/singletons-in-javascript/</link>
	<description></description>
	<lastBuildDate>Mon, 19 Dec 2011 08:17:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jonathan Fingland</title>
		<link>http://www.ashita.org/singletons-in-javascript/comment-page-1/#comment-141</link>
		<dc:creator>Jonathan Fingland</dc:creator>
		<pubDate>Sat, 05 Dec 2009 05:45:07 +0000</pubDate>
		<guid isPermaLink="false">http://ashita.org/?p=329#comment-141</guid>
		<description>@peter 
I really wish there were. The problem is this: You can&#039;t make an object un-instantiable as there are no private constructors -- just prototypes. You can control scope somewhat, and that&#039;s what I&#039;ve done above. By nesting your constructor inside another function, the global scope doesn&#039;t have visibility of the constructor. And if scripts can&#039;t see it, then they can&#039;t instantiate it. However, if scripts can&#039;t see it, then they also can&#039;t verify what it is -- hence why instanceof fails. 

The one option that might work is to create a constructor function that throws an exception if it has already been instantiated before. In fact, I&#039;ll add that to the post above.</description>
		<content:encoded><![CDATA[<p>@peter<br />
I really wish there were. The problem is this: You can&#8217;t make an object un-instantiable as there are no private constructors &#8212; just prototypes. You can control scope somewhat, and that&#8217;s what I&#8217;ve done above. By nesting your constructor inside another function, the global scope doesn&#8217;t have visibility of the constructor. And if scripts can&#8217;t see it, then they can&#8217;t instantiate it. However, if scripts can&#8217;t see it, then they also can&#8217;t verify what it is &#8212; hence why instanceof fails. </p>
<p>The one option that might work is to create a constructor function that throws an exception if it has already been instantiated before. In fact, I&#8217;ll add that to the post above.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Robinett</title>
		<link>http://www.ashita.org/singletons-in-javascript/comment-page-1/#comment-139</link>
		<dc:creator>Peter Robinett</dc:creator>
		<pubDate>Sat, 05 Dec 2009 00:35:40 +0000</pubDate>
		<guid isPermaLink="false">http://ashita.org/?p=329#comment-139</guid>
		<description>Hi Jonathan,

Is there a way to avoid those invalid instanceof operand errors? I&#039;ve got some code I can&#039;t easily change and would like to be able to use instanceof.

Thanks,
Peter Robinett</description>
		<content:encoded><![CDATA[<p>Hi Jonathan,</p>
<p>Is there a way to avoid those invalid instanceof operand errors? I&#8217;ve got some code I can&#8217;t easily change and would like to be able to use instanceof.</p>
<p>Thanks,<br />
Peter Robinett</p>
]]></content:encoded>
	</item>
</channel>
</rss>

