<?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: Getters and Setters in JavaScript</title>
	<atom:link href="http://ajaxian.com/archives/getters-and-setters-in-javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/getters-and-setters-in-javascript</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: Victor Nazarov</title>
		<link>http://ajaxian.com/archives/getters-and-setters-in-javascript/comment-page-1#comment-252686</link>
		<dc:creator>Victor Nazarov</dc:creator>
		<pubDate>Fri, 13 Jul 2007 21:01:35 +0000</pubDate>
		<guid isPermaLink="false">http://test.ajaxian.com/archives/getters-and-setters-in-javascript#comment-252686</guid>
		<description>&gt;Constructor.prototype = {
&gt;publicList: [],
&gt;
&gt;get publicLength () {
&gt;return this.publicList.length
&gt;}
&gt;}

I think, that better don&#039;t write getters like this. May be it works, but code is smelling...</description>
		<content:encoded><![CDATA[<p>&gt;Constructor.prototype = {<br />
&gt;publicList: [],<br />
&gt;<br />
&gt;get publicLength () {<br />
&gt;return this.publicList.length<br />
&gt;}<br />
&gt;}</p>
<p>I think, that better don&#8217;t write getters like this. May be it works, but code is smelling&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Modular Homes</title>
		<link>http://ajaxian.com/archives/getters-and-setters-in-javascript/comment-page-1#comment-251455</link>
		<dc:creator>Modular Homes</dc:creator>
		<pubDate>Tue, 12 Jun 2007 14:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://test.ajaxian.com/archives/getters-and-setters-in-javascript#comment-251455</guid>
		<description>Find a modular homes builder to construct your dream home.</description>
		<content:encoded><![CDATA[<p>Find a modular homes builder to construct your dream home.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Higginbotham</title>
		<link>http://ajaxian.com/archives/getters-and-setters-in-javascript/comment-page-1#comment-245360</link>
		<dc:creator>Daniel Higginbotham</dc:creator>
		<pubDate>Mon, 18 Dec 2006 20:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://test.ajaxian.com/archives/getters-and-setters-in-javascript#comment-245360</guid>
		<description>Is there any way to test whether a method is a getter or setter?</description>
		<content:encoded><![CDATA[<p>Is there any way to test whether a method is a getter or setter?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: atleta</title>
		<link>http://ajaxian.com/archives/getters-and-setters-in-javascript/comment-page-1#comment-1664</link>
		<dc:creator>atleta</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://test.ajaxian.com/archives/getters-and-setters-in-javascript#comment-1664</guid>
		<description>Yep... this is an almost exact copy from the devmo (mozilla developer) JS documentation. What I can&#039;t find there however is how do you define getters and setters in a constructor function (or using the .prototype form)?

Because it&#039;s quite rare (I think) to declare a concrete object out of the (or into the :) ) blue. But usually we create classes (i.e. multiple instances of the same object). But this form only works concrete object creation.</description>
		<content:encoded><![CDATA[<p>Yep&#8230; this is an almost exact copy from the devmo (mozilla developer) JS documentation. What I can&#8217;t find there however is how do you define getters and setters in a constructor function (or using the .prototype form)?</p>
<p>Because it&#8217;s quite rare (I think) to declare a concrete object out of the (or into the :) ) blue. But usually we create classes (i.e. multiple instances of the same object). But this form only works concrete object creation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan SundstrÃ¶m</title>
		<link>http://ajaxian.com/archives/getters-and-setters-in-javascript/comment-page-1#comment-1665</link>
		<dc:creator>Johan SundstrÃ¶m</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://test.ajaxian.com/archives/getters-and-setters-in-javascript#comment-1665</guid>
		<description>This may come out a bit harsh, due in part to the late hour. I always find it a bit unfortunate when influential blogs mention powerful concepts like these, though, without a context of when or how they can be put to good use, rather than making code harder to read, understand and debug, or less portable, as is the case in these two examples.

First, by changing the expected results of a few very basic lines of code that surface wise seem not to do any destructive changes on a, then by changing the semantics of base language parts, which serves to make your code blend worse with code not invented here.

Used right, they are powerful tools that can be put to use to maintain backwards compatibility with archaic APIs you otherwise would have had to leave behind, for instance. - Without making those parts of the code added for the legacy support add much clutter to your code base, nonetheless.</description>
		<content:encoded><![CDATA[<p>This may come out a bit harsh, due in part to the late hour. I always find it a bit unfortunate when influential blogs mention powerful concepts like these, though, without a context of when or how they can be put to good use, rather than making code harder to read, understand and debug, or less portable, as is the case in these two examples.</p>
<p>First, by changing the expected results of a few very basic lines of code that surface wise seem not to do any destructive changes on a, then by changing the semantics of base language parts, which serves to make your code blend worse with code not invented here.</p>
<p>Used right, they are powerful tools that can be put to use to maintain backwards compatibility with archaic APIs you otherwise would have had to leave behind, for instance. &#8211; Without making those parts of the code added for the legacy support add much clutter to your code base, nonetheless.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jun Yang</title>
		<link>http://ajaxian.com/archives/getters-and-setters-in-javascript/comment-page-1#comment-1666</link>
		<dc:creator>Jun Yang</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://test.ajaxian.com/archives/getters-and-setters-in-javascript#comment-1666</guid>
		<description>Good pointer.  I guess this is not supported in IE?  I tried it with Rhino 1.6R2 and it is not supported there.  Is this part of the standard BTW?</description>
		<content:encoded><![CDATA[<p>Good pointer.  I guess this is not supported in IE?  I tried it with Rhino 1.6R2 and it is not supported there.  Is this part of the standard BTW?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott McCoy</title>
		<link>http://ajaxian.com/archives/getters-and-setters-in-javascript/comment-page-1#comment-1667</link>
		<dc:creator>Scott McCoy</dc:creator>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://test.ajaxian.com/archives/getters-and-setters-in-javascript#comment-1667</guid>
		<description>Last I checked, Microsoft&#039;s JScript (or IE) ECMA implementation does not support setters and getters in any form.

During object construction, one of two approaches may be used, obviously since you can do this in the prototype exactly as the syntax above, since an object prototype is simply an object itself.

In order to provide lexical access to local data in a constructor itself (aka. private data), below is an example of both approaches:

function Constructor () {
    var foo = []

    this.length getter = function () { 
        return foo.length 
    }
}
Constructor.prototype = {
    publicList: [],

    get publicLength () { 
        return this.publicList.length 
    }
}

This way you can dynamically set the getter or setter of any property.

As far as being a part of a specification, this was originally extracted from the ESR4 proposal, which also adds a bunch of unneccesary crap...but this is one of the useful features it adds :-)  It&#039;s true that rhino should support this but it doesn&#039;t, patches are welcome.

This web application could use some advanced formatting.
</description>
		<content:encoded><![CDATA[<p>Last I checked, Microsoft&#8217;s JScript (or IE) ECMA implementation does not support setters and getters in any form.</p>
<p>During object construction, one of two approaches may be used, obviously since you can do this in the prototype exactly as the syntax above, since an object prototype is simply an object itself.</p>
<p>In order to provide lexical access to local data in a constructor itself (aka. private data), below is an example of both approaches:</p>
<p>function Constructor () {<br />
    var foo = []</p>
<p>    this.length getter = function () {<br />
        return foo.length<br />
    }<br />
}<br />
Constructor.prototype = {<br />
    publicList: [],</p>
<p>    get publicLength () {<br />
        return this.publicList.length<br />
    }<br />
}</p>
<p>This way you can dynamically set the getter or setter of any property.</p>
<p>As far as being a part of a specification, this was originally extracted from the ESR4 proposal, which also adds a bunch of unneccesary crap&#8230;but this is one of the useful features it adds :-)  It&#8217;s true that rhino should support this but it doesn&#8217;t, patches are welcome.</p>
<p>This web application could use some advanced formatting.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

