<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>SYSK 337:  JavaScript – Should You Define Functions Inside a Prototype or Outside?</title><link>http://blogs.msdn.com/irenak/archive/2007/04/26/sysk-337-javascript-should-you-define-functions-inside-a-prototype-or-outside.aspx</link><description>Yesterday’s post described three ways to extend an existing type. It occurred to me that there is one more, slightly different mechanism, for defining a prototype function… you can think of it as Method 2-b. Consider the following: function TestClass(param1)</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: SYSK 337:  JavaScript – Should You Define Functions Inside a Prototype or Outside?</title><link>http://blogs.msdn.com/irenak/archive/2007/04/26/sysk-337-javascript-should-you-define-functions-inside-a-prototype-or-outside.aspx#2290734</link><pubDate>Fri, 27 Apr 2007 01:00:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2290734</guid><dc:creator>Bruce</dc:creator><description>&lt;p&gt;Doesn't that blow away any existing stuff in the prototype? &amp;nbsp;Could you do something like this instead:&lt;/p&gt;
&lt;p&gt;function TestClass(param1)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;this._param1 = param1;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;TestClass.prototype.get_param1 = function TestClass$get_param1()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return this._param1;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;</description></item><item><title>re: Reply to Bruce</title><link>http://blogs.msdn.com/irenak/archive/2007/04/26/sysk-337-javascript-should-you-define-functions-inside-a-prototype-or-outside.aspx#2291697</link><pubDate>Fri, 27 Apr 2007 02:21:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2291697</guid><dc:creator>irenak</dc:creator><description>&lt;p&gt;You can use commans as a function separator, e.g.&lt;/p&gt;
&lt;p&gt;TestClass.prototype = &lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;get_param1: TestClass$get_param1,&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;set_param1: TestClass$set_param1&lt;/p&gt;
&lt;p&gt;} &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Having said that, your solution would work as well :)&lt;/p&gt;
</description></item></channel></rss>