<?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: JavaScript parasitic inheritance, power constructors and instanceof.</title>
	<atom:link href="http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/</link>
	<description>topics: functional programming, concurrency, web-development, REST, dynamic languages</description>
	<lastBuildDate>Tue, 17 Aug 2010 07:43:11 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: admin</title>
		<link>http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/comment-page-1/#comment-27</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 29 Aug 2008 15:40:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/#comment-27</guid>
		<description>Yes, I can think of no use for this feature right now  ;-) 

But it is certainly something which is nice to know since it can be the cause of some pretty nasty bugs.

/Karl</description>
		<content:encoded><![CDATA[<p>Yes, I can think of no use for this feature right now  <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  </p>
<p>But it is certainly something which is nice to know since it can be the cause of some pretty nasty bugs.</p>
<p>/Karl</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julian Turner</title>
		<link>http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/comment-page-1/#comment-26</link>
		<dc:creator>Julian Turner</dc:creator>
		<pubDate>Fri, 29 Aug 2008 14:59:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/#comment-26</guid>
		<description>Interesting, so that means you can achieve some obscure &quot;by reference&quot; type effects, by passing the arguments object around.

E.g.

function foo(a, b)
{
     bar(arguments);
     alert(a + b);
}

function bar(args)
{
     args[0] = args[0] + 1;
}

foo(1, 2); // alerts 4 in IE

Not sure what use this might be in practice!</description>
		<content:encoded><![CDATA[<p>Interesting, so that means you can achieve some obscure &#8220;by reference&#8221; type effects, by passing the arguments object around.</p>
<p>E.g.</p>
<p>function foo(a, b)<br />
{<br />
     bar(arguments);<br />
     alert(a + b);<br />
}</p>
<p>function bar(args)<br />
{<br />
     args[0] = args[0] + 1;<br />
}</p>
<p>foo(1, 2); // alerts 4 in IE</p>
<p>Not sure what use this might be in practice!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/comment-page-1/#comment-9</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Tue, 05 Aug 2008 13:48:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/#comment-9</guid>
		<description>Yes, exactly. Honestly, I wasn&#039;t aware of this until after I writing and debugging the function! ;-)

For the formal reference: 

In ECMA-263, 10.1.8 Arguments Object it says: ... an arguments object is created and initialised as follows: 

...
* For each non-negative integer, arg, less than the value of the length property, a property is created with name ToString(arg) and property attributes {DontEnum}. The initial value of this property is 
the value of the corresponding actual parameter supplied by the caller. The first actual parameter 
value corresponds to arg=0, the second to arg=1, and so on. **In the case when arg is less than the 
number of formal parameters for the Function object, this property shares its value with the 
corresponding property of the activation object. This means that changing this property changes the corresponding property of the activation object and vice versa.**</description>
		<content:encoded><![CDATA[<p>Yes, exactly. Honestly, I wasn&#8217;t aware of this until after I writing and debugging the function! <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>For the formal reference: </p>
<p>In ECMA-263, 10.1.8 Arguments Object it says: &#8230; an arguments object is created and initialised as follows: </p>
<p>&#8230;<br />
* For each non-negative integer, arg, less than the value of the length property, a property is created with name ToString(arg) and property attributes {DontEnum}. The initial value of this property is<br />
the value of the corresponding actual parameter supplied by the caller. The first actual parameter<br />
value corresponds to arg=0, the second to arg=1, and so on. **In the case when arg is less than the<br />
number of formal parameters for the Function object, this property shares its value with the<br />
corresponding property of the activation object. This means that changing this property changes the corresponding property of the activation object and vice versa.**</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Julian Turner</title>
		<link>http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/comment-page-1/#comment-8</link>
		<dc:creator>Julian Turner</dc:creator>
		<pubDate>Tue, 05 Aug 2008 12:26:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/#comment-8</guid>
		<description>p = proto;//exercise: why?

My guess is:-

1.  We know that if you change a value in the arguments array, e.g. arguments[1] = &quot;New Value&quot;, then the local variable for position 1 will be updated.  I.e. in your case &quot;proto would now contain the string &quot;New Value&quot;.

2.  Your &quot;slice(arguments, 0, 0)&quot; inserts a new value in position arguments[0], movement the original &quot;conf&quot; (index 0) and &quot;proto&quot; (index 1) values up one index position in the arguments array.

3.  This movement is equivalent to assigning a new value, and so the &quot;proto&quot; variable will now contain the &quot;conf&quot; contents. 

4.  This movement up occurs before the &quot;function&quot; object you insert at the start is called.  So by the time the function is called, the specifc &quot;proto&quot; variable (on the activation/variable object captured by the closure of the inner function) would have changed.  So &quot;proto&quot; would point to the wrong value when it came to be used in the inner function.</description>
		<content:encoded><![CDATA[<p>p = proto;//exercise: why?</p>
<p>My guess is:-</p>
<p>1.  We know that if you change a value in the arguments array, e.g. arguments[1] = &#8220;New Value&#8221;, then the local variable for position 1 will be updated.  I.e. in your case &#8220;proto would now contain the string &#8220;New Value&#8221;.</p>
<p>2.  Your &#8220;slice(arguments, 0, 0)&#8221; inserts a new value in position arguments[0], movement the original &#8220;conf&#8221; (index 0) and &#8220;proto&#8221; (index 1) values up one index position in the arguments array.</p>
<p>3.  This movement is equivalent to assigning a new value, and so the &#8220;proto&#8221; variable will now contain the &#8220;conf&#8221; contents. </p>
<p>4.  This movement up occurs before the &#8220;function&#8221; object you insert at the start is called.  So by the time the function is called, the specifc &#8220;proto&#8221; variable (on the activation/variable object captured by the closure of the inner function) would have changed.  So &#8220;proto&#8221; would point to the wrong value when it came to be used in the inner function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AaronNGray</title>
		<link>http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/comment-page-1/#comment-3</link>
		<dc:creator>AaronNGray</dc:creator>
		<pubDate>Wed, 02 Jul 2008 00:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.higher-order.net/2008/02/21/javascript-parasitic-inheritance-power-constructors-and-instanceof/#comment-3</guid>
		<description>p = proto;//exercise: why?&lt;br/&gt;&lt;br/&gt;I believe this is due to how Javascript&#039;s closures work.</description>
		<content:encoded><![CDATA[<p>p = proto;//exercise: why?</p>
<p>I believe this is due to how Javascript&#8217;s closures work.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
