<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Careful with that prototype, Eugene</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx</link><description>Here&amp;#39;s one that could cost you some long and puzzling debugging sessions. What&amp;#39;s the difference between Foo.Bar = function () { this .number = 0; this .stuff = {}; } Foo.Bar. prototype . toString = function () { return &amp;quot; Bar # &amp;quot; + this</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: Careful with that prototype, Eugene</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#934563</link><pubDate>Wed, 15 Nov 2006 22:20:50 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:934563</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;Patrick: sure, that's what we're doing in ASP.NET AJAX, see my more recent posts on prototype. In this post, I tried to keep it simple and without dependancy on AJAX.&lt;/p&gt;
&lt;p&gt;The problem with your code if you add nothing else is that you broke the prototype's constructor by overwriting the whole prototype with a JSON object. We solve this in the AJAX Library by resetting prototype.constructor to Foo.Bar from the class registration method.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=934563" width="1" height="1"&gt;</description></item><item><title>another way</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#933751</link><pubDate>Wed, 15 Nov 2006 19:17:02 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:933751</guid><dc:creator>Patrick J. Fox</dc:creator><author>Patrick J. Fox</author><description>Bertand - 

Thanks for your informative posts.

I tired out he example and came up with a combination of the two patterns shownm above:

&lt;pre&gt;
Foo.Bar = function() {
		this.stuff = {}
	}
Foo.Bar.prototype = {
	number: 0,
	toString: function() {
  	return "Bar #" + this.number + (this.stuff.id || "");
	}
}
&lt;/pre&gt;

Any reason why someone shouldn't code it this way?&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=933751" width="1" height="1"&gt;</description></item><item><title>New Microsoft ASP.NET AJAX CTP Coming Soon</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#676650</link><pubDate>Tue, 17 Oct 2006 21:40:30 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:676650</guid><dc:creator>inventive title</dc:creator><author>inventive title</author><description>&lt;p&gt;Microsoft has been hard at work on the next Microsoft ASP.NET AJAX (formerly &amp;amp;quot;Atlas&amp;amp;quot;) CTP,&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=676650" width="1" height="1"&gt;</description></item><item><title>From closures to prototypes, part 2</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#661685</link><pubDate>Sat, 14 Oct 2006 07:28:11 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:661685</guid><dc:creator>Atlas and more</dc:creator><author>Atlas and more</author><description>&lt;p&gt;In part 1 of this post, I exposed the differences between the closure and the prototype patterns to define&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=661685" width="1" height="1"&gt;</description></item><item><title>Be prepared for the next MS AJAX bits</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#653395</link><pubDate>Wed, 11 Oct 2006 17:52:06 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:653395</guid><dc:creator>Atlas notes</dc:creator><author>Atlas notes</author><description>&lt;p&gt;It seems that the next MS AJAX preview will be very, very different from the previous CTP. Bertrand Le&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=653395" width="1" height="1"&gt;</description></item><item><title>re: Careful with that prototype, Eugene</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#653267</link><pubDate>Wed, 11 Oct 2006 16:18:40 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:653267</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;Craig. Read on to the next article: &lt;a rel="nofollow" target="_new" href="http://weblogs.asp.net/bleroy/archive/2006/10/11/From-closures-to-prototypes_2C00_-part-1.aspx"&gt;http://weblogs.asp.net/bleroy/archive/2006/10/11/From-closures-to-prototypes_2C00_-part-1.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;:)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=653267" width="1" height="1"&gt;</description></item><item><title>More info on &amp;quot;prototype&amp;quot; and &amp;quot;closure&amp;quot;</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#652911</link><pubDate>Wed, 11 Oct 2006 12:01:38 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:652911</guid><dc:creator>Craig Serold</dc:creator><author>Craig Serold</author><description>Hey guys, I'm pretty green on javascript/Atlas script.  do you guys have any suggested reading for learning more about the prototype and closure references you make here?  Thanks! &lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=652911" width="1" height="1"&gt;</description></item><item><title>re: Careful with that prototype, Eugene</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#640731</link><pubDate>Mon, 09 Oct 2006 22:24:23 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:640731</guid><dc:creator>Manuel Abadia</dc:creator><author>Manuel Abadia</author><description>Bertrand: Thanks for the information. As the last release was a few months ago I'm a bit impatient to get the latests bits in my hands. The post you talk about sounds really interesting...&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=640731" width="1" height="1"&gt;</description></item><item><title>re: Careful with that prototype, Eugene</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#640206</link><pubDate>Mon, 09 Oct 2006 18:49:39 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:640206</guid><dc:creator>Bertrand Le Roy</dc:creator><author>Bertrand Le Roy</author><description>&lt;p&gt;Manuel: we're working really hard on the new CTP currently. I can't tell you when it will be ready exactly yet, but we're doing everthing we can to get that into your hands as soon as possible.&lt;/p&gt;
&lt;p&gt;I'll make another post soon about the transition from closure to prototype, its motivations and caveats.&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=640206" width="1" height="1"&gt;</description></item><item><title>re: Careful with that prototype, Eugene</title><link>http://weblogs.asp.net/bleroy/archive/2006/10/07/Careful-with-that-prototype_2C00_-Eugene.aspx#640101</link><pubDate>Mon, 09 Oct 2006 17:46:39 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:640101</guid><dc:creator>Garbin</dc:creator><author>Garbin</author><description>Hi,

I still remember that headache... I've read about this tip only in a book entirely dedicated to JavaScript. Thanks for sharing it.&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=640101" width="1" height="1"&gt;</description></item></channel></rss>