<?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: Overloading functions in JavaScript</title>
	<atom:link href="http://blog.mastykarz.nl/overloading-functions-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mastykarz.nl/overloading-functions-javascript/</link>
	<description>Innovation Matters &#124; SharePoint Server MVP &#124; ISSN 2210-9390</description>
	<lastBuildDate>Thu, 09 Feb 2012 05:22:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Dinesh Bolkensteyn</title>
		<link>http://blog.mastykarz.nl/overloading-functions-javascript/comment-page-1/#comment-42913</link>
		<dc:creator>Dinesh Bolkensteyn</dc:creator>
		<pubDate>Mon, 15 Feb 2010 09:39:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/overloading-functions-javascript/#comment-42913</guid>
		<description>@Micheal: In this case you had prior knowledge about the already existing function. So basically, you duplicated the old function within your new one.

Now this is not possible if you do not know the previously defined function (from another SharePoint solution, another WebPart, whatever).

Example: In MOSS 2007, when one wanted to extend the context menu on list items elements, one would have to define a custom javascript function (with a hardcoded name defined somewhere in Core.js). The problem with this approach is that two solutions would not be able to extend the context menu at the same time, because of overriding (overloading would not have helped to solve this one). A better solution would probably have been to have to register the custom javascript funtions so that several ones could be active at the same time.</description>
		<content:encoded><![CDATA[<p>@Micheal: In this case you had prior knowledge about the already existing function. So basically, you duplicated the old function within your new one.</p>
<p>Now this is not possible if you do not know the previously defined function (from another SharePoint solution, another WebPart, whatever).</p>
<p>Example: In MOSS 2007, when one wanted to extend the context menu on list items elements, one would have to define a custom javascript function (with a hardcoded name defined somewhere in Core.js). The problem with this approach is that two solutions would not be able to extend the context menu at the same time, because of overriding (overloading would not have helped to solve this one). A better solution would probably have been to have to register the custom javascript funtions so that several ones could be active at the same time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael A. Vickers</title>
		<link>http://blog.mastykarz.nl/overloading-functions-javascript/comment-page-1/#comment-41769</link>
		<dc:creator>Michael A. Vickers</dc:creator>
		<pubDate>Wed, 03 Feb 2010 01:21:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/overloading-functions-javascript/#comment-41769</guid>
		<description>@Waldek: Perhaps by definition it&#039;s not the same thing and programmatically it&#039;s a little different -- in C# you would create multiple methods vs. javascript you would tuck the guts of those different methods into the same function. 

In the end though you come out with the same result -- being able to call the same-named function/method with a different number of parameters/parameter types.</description>
		<content:encoded><![CDATA[<p>@Waldek: Perhaps by definition it&#039;s not the same thing and programmatically it&#039;s a little different &#8212; in C# you would create multiple methods vs. javascript you would tuck the guts of those different methods into the same function. </p>
<p>In the end though you come out with the same result &#8212; being able to call the same-named function/method with a different number of parameters/parameter types.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Waldek Mastykarz</title>
		<link>http://blog.mastykarz.nl/overloading-functions-javascript/comment-page-1/#comment-41525</link>
		<dc:creator>Waldek Mastykarz</dc:creator>
		<pubDate>Sun, 31 Jan 2010 09:30:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/overloading-functions-javascript/#comment-41525</guid>
		<description>@Michael: It&#039;s not really overloading, is it? You can do some different logic depending on the number of arguments but still it all needs to be done within a single function.</description>
		<content:encoded><![CDATA[<p>@Michael: It&#039;s not really overloading, is it? You can do some different logic depending on the number of arguments but still it all needs to be done within a single function.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael A. Vickers</title>
		<link>http://blog.mastykarz.nl/overloading-functions-javascript/comment-page-1/#comment-41486</link>
		<dc:creator>Michael A. Vickers</dc:creator>
		<pubDate>Sat, 30 Jan 2010 22:32:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.mastykarz.nl/overloading-functions-javascript/#comment-41486</guid>
		<description>Javascript does support overloading, but not the same way as C#.

function addNumbers() {
   if(arguments.length==2)
      return(
         arguments[0] + 
         arguments[1]
      );
   if(arguments.length==3)
      return(
         arguments[0] + 
         arguments[1] + 
         arguments[2]
      );
}

Or, more succinctly:

function addNumbers(){
   var r=0;
   for(var i=0;i&lt;arguments.length;i++){
      r+=arguments[i];
   }
   return(r);
}</description>
		<content:encoded><![CDATA[<p>Javascript does support overloading, but not the same way as C#.</p>
<p>function addNumbers() {<br />
   if(arguments.length==2)<br />
      return(<br />
         arguments[0] +<br />
         arguments[1]<br />
      );<br />
   if(arguments.length==3)<br />
      return(<br />
         arguments[0] +<br />
         arguments[1] +<br />
         arguments[2]<br />
      );<br />
}</p>
<p>Or, more succinctly:</p>
<p>function addNumbers(){<br />
   var r=0;<br />
   for(var i=0;i&lt;arguments.length;i++){<br />
      r+=arguments[i];<br />
   }<br />
   return(r);<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

