<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
				<title>Comments on: OOP in JavaScript - Part 2: Static classes and Singleton</title>
		<link>http://www.phpdevblog.net/2009/09/oop-in-javascript-part-2-static-classes-and-singleton.html</link>
		<description>OOP in JavaScript - Part 2: Static classes and Singleton Comment Feed</description>
				<language>de</language>
		<pubDate>Thu, 09 Sep 2010 19:25:59 +0000</pubDate>
		<generator>mcw[blog] 'Ruby' Alpha 3</generator>
		<item>
			<title>Comment #1 by: Matthew Maxwell</title>
			<link>http://www.phpdevblog.net/2009/09/oop-in-javascript-part-2-static-classes-and-singleton.html#comment4741</link>
			<guid>http://www.phpdevblog.net/2009/09/oop-in-javascript-part-2-static-classes-and-singleton.html#comment4741</guid>
			<author>Matthew Maxwell</author>			
			<pubDate>Tue, 15 Sep 2009 16:02:05 +0000</pubDate>
			<content:encoded><![CDATA[ You can do private-like variables in JavaScript:<br />
<br />
function Registry() {<br />
    var _data = {}<br />
    var that = this; // scope resolution for chaining<br />
    this.set = function (key, value) {<br />
        _data[key] = value;<br />
        return that; // returns our Registry object<br />
    };<br />
    this.get = function (key) {<br />
        return _data[key];<br />
    };<br />
}<br />
<br />
Now, you could instantiate a new Registry:<br />
var reg = new Registry();<br />
<br />
reg._data // undefined<br />
<br />
reg.set("userIsAuthorized", false); // returns reg, so we could chain with other commands<br />
<br />
reg.get("userIsAuthorized") // false<br />
<br />
reg._data // undefined<br />
<br />
If we view reg, _data will not be seen, and is therefore a "private" variable in the JavaScript class. ]]></content:encoded>
		</item>
		<item>
			<title>Comment #2 by: Matthew Maxwell</title>
			<link>http://www.phpdevblog.net/2009/09/oop-in-javascript-part-2-static-classes-and-singleton.html#comment4742</link>
			<guid>http://www.phpdevblog.net/2009/09/oop-in-javascript-part-2-static-classes-and-singleton.html#comment4742</guid>
			<author>Matthew Maxwell</author>			
			<pubDate>Tue, 15 Sep 2009 16:04:48 +0000</pubDate>
			<content:encoded><![CDATA[ Just realized that the format of that is ugly and I forgot a semicolon after var _data = {}; Sorry about that :( ]]></content:encoded>
		</item>
		<item>
			<title>Comment #3 by: Dominik Jungowski</title>
			<link>http://www.phpdevblog.net/2009/09/oop-in-javascript-part-2-static-classes-and-singleton.html#comment4773</link>
			<guid>http://www.phpdevblog.net/2009/09/oop-in-javascript-part-2-static-classes-and-singleton.html#comment4773</guid>
			<author>Dominik Jungowski</author>			
			<pubDate>Wed, 16 Sep 2009 16:11:10 +0000</pubDate>
			<content:encoded><![CDATA[ Yupp, thanks. Paul already showed me that way in the comments for OOP in JS Part 1 ]]></content:encoded>
		</item>
		<item>
			<title>Comment #4 by: Cell phone batteries wholesale</title>
			<link>http://www.phpdevblog.net/2009/09/oop-in-javascript-part-2-static-classes-and-singleton.html#comment12726</link>
			<guid>http://www.phpdevblog.net/2009/09/oop-in-javascript-part-2-static-classes-and-singleton.html#comment12726</guid>
			<author>Cell phone batteries wholesale</author>			
			<pubDate>Sun, 28 Mar 2010 06:42:56 +0000</pubDate>
			<content:encoded><![CDATA[ Good points…I would note that as someone who really doesn’t write on blogs much (in fact, this may be my first post), I don’t think the term “lurker” is very becoming to a non-posting reader. It’s not your fault really , but perhaps the blogosphere could come up with a better, non-creepy name for the 90% of us that enjoy reading the posts. ]]></content:encoded>
		</item>
		</channel>
</rss>