<?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: ECMA-262-5 in detail. Chapter 1. Properties and Property Descriptors.</title>
	<atom:link href="http://dmitrysoshnikov.com/ecmascript/es5-chapter-1-properties-and-property-descriptors/feed/" rel="self" type="application/rss+xml" />
	<link>http://dmitrysoshnikov.com/ecmascript/es5-chapter-1-properties-and-property-descriptors/</link>
	<description>by Dmitry Soshnikov</description>
	<lastBuildDate>Sat, 04 Feb 2012 03:57:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Dmitry Soshnikov</title>
		<link>http://dmitrysoshnikov.com/ecmascript/es5-chapter-1-properties-and-property-descriptors/comment-page-1/#comment-12290</link>
		<dc:creator>Dmitry Soshnikov</dc:creator>
		<pubDate>Wed, 25 Jan 2012 04:43:34 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=1183#comment-12290</guid>
		<description>@&lt;b&gt;LCamel&lt;/b&gt;, yes, &quot;attributes&quot; sounds better in this case (though, if to treat a property as an object, then then property may have properties, or, yes -- attributes); fixed.</description>
		<content:encoded><![CDATA[<p>@<b>LCamel</b>, yes, &#8220;attributes&#8221; sounds better in this case (though, if to treat a property as an object, then then property may have properties, or, yes &#8212; attributes); fixed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LCamel</title>
		<link>http://dmitrysoshnikov.com/ecmascript/es5-chapter-1-properties-and-property-descriptors/comment-page-1/#comment-12289</link>
		<dc:creator>LCamel</dc:creator>
		<pubDate>Wed, 25 Jan 2012 04:37:08 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=1183#comment-12289</guid>
		<description>&quot;In addition to general attributes, an accessor property has the following properties which related with a getter and a setter respectively&quot;

should be

&quot;In addition to general attributes, an accessor property has the following *attributes* which related with a getter and a setter respectively&quot;</description>
		<content:encoded><![CDATA[<p>&#8220;In addition to general attributes, an accessor property has the following properties which related with a getter and a setter respectively&#8221;</p>
<p>should be</p>
<p>&#8220;In addition to general attributes, an accessor property has the following *attributes* which related with a getter and a setter respectively&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry A. Soshnikov</title>
		<link>http://dmitrysoshnikov.com/ecmascript/es5-chapter-1-properties-and-property-descriptors/comment-page-1/#comment-361</link>
		<dc:creator>Dmitry A. Soshnikov</dc:creator>
		<pubDate>Fri, 30 Apr 2010 10:56:23 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=1183#comment-361</guid>
		<description>@&lt;b&gt;Jens&lt;/b&gt;

thanks.

@&lt;b&gt;kangax&lt;/b&gt;

thanks for additions.

&lt;blockquote&gt;Of course data descriptor is created _not only_ when corresponding object is empty, but also when &quot;writable&quot; or &quot;value&quot; properties are present (you only mention empty and get/set).&lt;/blockquote&gt;

Yes, of course, but this case seems obvious. The main goal is to specify what happens when we have an &lt;em&gt;empty&lt;/em&gt; descriptor object. Although, I added this case too.

&lt;blockquote&gt;You can also mention that `TypeError` is supposed to be thrown when creating a property descriptor out of an object that has both “value”/”writable” and “get”/”set” properties (as per 8.10.5 — ToPropertyDescriptor).&lt;/blockquote&gt;

Yes, added.

&lt;blockquote&gt;It might not be obvious, but property can only be overwritten when its [[Configurable]] is not `false`. Since in this example we do not set [[Configurable]] explicitly and its default value is `false`, the property can not be overwritten and an error is thrown. Defining it with [[Configurable]] == true obviously &quot;solves&quot; the problem:&lt;/blockquote&gt;

Yup, also a good addition. Although, it is mentioned in the [[Configurable]] attribute definition, it is good to specify this case explicitly.

By the way, the error is not thrown if reconfiguring attribute&#039;s value (a getter in this case) is the same (because of &lt;em&gt;SameValue&lt;/em&gt; check in 8.12.9). But practically such &quot;re&quot;-configuration seems useless.

I mentioned all that cases, though.

&lt;blockquote&gt;Btw, does generic descriptor (which should be created if object is empty) serve any useful purpose?&lt;/blockquote&gt;

No, don&#039;t think so. At least -- not for ECMAScript program. Of course, it serves a useful purpose on implementation level. See again &quot;8.12.9 [[DefineOwnProperty]]&quot;, where checks such as &lt;em&gt;IsGenericDescriptor&lt;/em&gt; and other are everywhere. There also said, that default value for absent attributes is &lt;em&gt;false&lt;/em&gt;, so for the ECMAScript program it doesn&#039;t matter.

Dmitry.</description>
		<content:encoded><![CDATA[<p>@<b>Jens</b></p>
<p>thanks.</p>
<p>@<b>kangax</b></p>
<p>thanks for additions.</p>
<blockquote><p>Of course data descriptor is created _not only_ when corresponding object is empty, but also when &#8220;writable&#8221; or &#8220;value&#8221; properties are present (you only mention empty and get/set).</p></blockquote>
<p>Yes, of course, but this case seems obvious. The main goal is to specify what happens when we have an <em>empty</em> descriptor object. Although, I added this case too.</p>
<blockquote><p>You can also mention that `TypeError` is supposed to be thrown when creating a property descriptor out of an object that has both “value”/”writable” and “get”/”set” properties (as per 8.10.5 — ToPropertyDescriptor).</p></blockquote>
<p>Yes, added.</p>
<blockquote><p>It might not be obvious, but property can only be overwritten when its [[Configurable]] is not `false`. Since in this example we do not set [[Configurable]] explicitly and its default value is `false`, the property can not be overwritten and an error is thrown. Defining it with [[Configurable]] == true obviously &#8220;solves&#8221; the problem:</p></blockquote>
<p>Yup, also a good addition. Although, it is mentioned in the [[Configurable]] attribute definition, it is good to specify this case explicitly.</p>
<p>By the way, the error is not thrown if reconfiguring attribute&#8217;s value (a getter in this case) is the same (because of <em>SameValue</em> check in 8.12.9). But practically such &#8220;re&#8221;-configuration seems useless.</p>
<p>I mentioned all that cases, though.</p>
<blockquote><p>Btw, does generic descriptor (which should be created if object is empty) serve any useful purpose?</p></blockquote>
<p>No, don&#8217;t think so. At least &#8212; not for ECMAScript program. Of course, it serves a useful purpose on implementation level. See again &#8220;8.12.9 [[DefineOwnProperty]]&#8221;, where checks such as <em>IsGenericDescriptor</em> and other are everywhere. There also said, that default value for absent attributes is <em>false</em>, so for the ECMAScript program it doesn&#8217;t matter.</p>
<p>Dmitry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens</title>
		<link>http://dmitrysoshnikov.com/ecmascript/es5-chapter-1-properties-and-property-descriptors/comment-page-1/#comment-360</link>
		<dc:creator>Jens</dc:creator>
		<pubDate>Fri, 30 Apr 2010 07:37:09 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=1183#comment-360</guid>
		<description>Great article and... thank you!</description>
		<content:encoded><![CDATA[<p>Great article and&#8230; thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kangax</title>
		<link>http://dmitrysoshnikov.com/ecmascript/es5-chapter-1-properties-and-property-descriptors/comment-page-1/#comment-355</link>
		<dc:creator>kangax</dc:creator>
		<pubDate>Fri, 30 Apr 2010 04:07:11 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=1183#comment-355</guid>
		<description>Nice overview :)

Few things you might want to add:

&lt;cite&gt;&quot;all implementations creates a data property if corresponding descriptor is empty, and an accessor property if descriptor object has either a get or a set property&quot;&lt;/cite&gt;

Of course data descriptor is created _not only_ when corresponding object is empty, but also when &quot;writable&quot; or &quot;value&quot; properties are present (you only mention empty and get/set).

I find it easy to think about it in this way:

1) If object is empty or value/writable properties are present, data descriptor is created

2) If get/set properties are present, accessor descriptor is created

Btw, does generic descriptor (which should be created if object is empty) serve any useful purpose?

You can also mention that `TypeError` is supposed to be thrown when creating a property descriptor out of an object that has both &quot;value&quot;/&quot;writable&quot; and &quot;get&quot;/&quot;set&quot; properties (as per 8.10.5 — ToPropertyDescriptor).

Another &quot;gotcha&quot; I didn&#039;t see in the article is what happens when you try to overwrite accessor property. For example:


[js]var o = Object.defineProperty({ }, &#039;x&#039;, { 
  get: function(){ return &#039;bar&#039; } 
});

Object.defineProperty(o, &#039;x&#039;, {
  get: function(){ return &#039;baz&#039; }
});

o.x; // &quot;bar&quot;[/js]


It might not be obvious, but property can only be overwritten when its [[Configurable]] is not `false`. Since in this example we do not set [[Configurable]] explicitly and its default value is `false`, the property can not be overwritten and an error is thrown. Defining it with [[Configurable]] == true obviously &quot;solves&quot; the problem:


[js]var o = Object.defineProperty({ }, &#039;x&#039;, { 
  get: function(){ return &#039;bar&#039; },
  configurable: true
});

Object.defineProperty(o, &#039;x&#039;, {
  get: function(){ return &#039;baz&#039; }
});

o.x; // &quot;baz&quot;[/js]
</description>
		<content:encoded><![CDATA[<p>Nice overview <img src='http://dmitrysoshnikov.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Few things you might want to add:</p>
<p><cite>&#8220;all implementations creates a data property if corresponding descriptor is empty, and an accessor property if descriptor object has either a get or a set property&#8221;</cite></p>
<p>Of course data descriptor is created _not only_ when corresponding object is empty, but also when &#8220;writable&#8221; or &#8220;value&#8221; properties are present (you only mention empty and get/set).</p>
<p>I find it easy to think about it in this way:</p>
<p>1) If object is empty or value/writable properties are present, data descriptor is created</p>
<p>2) If get/set properties are present, accessor descriptor is created</p>
<p>Btw, does generic descriptor (which should be created if object is empty) serve any useful purpose?</p>
<p>You can also mention that `TypeError` is supposed to be thrown when creating a property descriptor out of an object that has both &#8220;value&#8221;/&#8221;writable&#8221; and &#8220;get&#8221;/&#8221;set&#8221; properties (as per 8.10.5 — ToPropertyDescriptor).</p>
<p>Another &#8220;gotcha&#8221; I didn&#8217;t see in the article is what happens when you try to overwrite accessor property. For example:</p>
<pre class="brush: jscript; title: ;">var o = Object.defineProperty({ }, 'x', {
  get: function(){ return 'bar' }
});

Object.defineProperty(o, 'x', {
  get: function(){ return 'baz' }
});

o.x; // &quot;bar&quot;</pre>
<p>It might not be obvious, but property can only be overwritten when its [[Configurable]] is not `false`. Since in this example we do not set [[Configurable]] explicitly and its default value is `false`, the property can not be overwritten and an error is thrown. Defining it with [[Configurable]] == true obviously &#8220;solves&#8221; the problem:</p>
<pre class="brush: jscript; title: ;">var o = Object.defineProperty({ }, 'x', {
  get: function(){ return 'bar' },
  configurable: true
});

Object.defineProperty(o, 'x', {
  get: function(){ return 'baz' }
});

o.x; // &quot;baz&quot;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dmitry A. Soshnikov</title>
		<link>http://dmitrysoshnikov.com/ecmascript/es5-chapter-1-properties-and-property-descriptors/comment-page-1/#comment-334</link>
		<dc:creator>Dmitry A. Soshnikov</dc:creator>
		<pubDate>Thu, 29 Apr 2010 12:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=1183#comment-334</guid>
		<description>@&lt;strong&gt;Anton&lt;/strong&gt;

Посмотрим. Возможно позже, когда я допишу все части этой новой серии на английском; параллельно вряд ли сейчас буду писать.

Но, этим может заняться кто-нибудь другой -- естественно заинтересованный в JS и в этом цикле статей. Отсюда тогда будут ссылки. Постепенно, я смогу проверить качество и точность перевода в техническом плане.</description>
		<content:encoded><![CDATA[<p>@<strong>Anton</strong></p>
<p>Посмотрим. Возможно позже, когда я допишу все части этой новой серии на английском; параллельно вряд ли сейчас буду писать.</p>
<p>Но, этим может заняться кто-нибудь другой &#8212; естественно заинтересованный в JS и в этом цикле статей. Отсюда тогда будут ссылки. Постепенно, я смогу проверить качество и точность перевода в техническом плане.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anton</title>
		<link>http://dmitrysoshnikov.com/ecmascript/es5-chapter-1-properties-and-property-descriptors/comment-page-1/#comment-333</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Thu, 29 Apr 2010 12:15:07 +0000</pubDate>
		<guid isPermaLink="false">http://dmitrysoshnikov.com/?p=1183#comment-333</guid>
		<description>Надеюсь это все-таки появится на русском, все-таки не так легко читается</description>
		<content:encoded><![CDATA[<p>Надеюсь это все-таки появится на русском, все-таки не так легко читается</p>
]]></content:encoded>
	</item>
</channel>
</rss>

