<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://united-coders.com"  xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>united-coders.com - function</title>
 <link>http://united-coders.com/taxonomy/term/45/0</link>
 <description></description>
 <language>en</language>
<item>
 <title>Handling the unexpected - Type safe functions in Javascript</title>
 <link>http://united-coders.com/matthias-reuter/handling-the-unexpected-type-safe-functions-in-javascript</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;Javascript is a weird language. Great but weird. Take functions for example. You cannot only pass any &lt;em&gt;type&lt;/em&gt; of arguments, you can also pass &lt;em&gt;any number&lt;/em&gt; of arguments. This may be quite disturbing, especially for Java developers. Recently I had a discussion with a Java developer who complained about missing code assistance in Javascript, by which he meant no hint about the type of an argument.&lt;/p&gt;
&lt;p&gt;This is of course due to the dynamically typed nature of Javascript. While in Java you denote the expected type of a parameter, and it&#039;s the caller&#039;s duty to pass the correct type (even more, you cannot pass a different type), in Javascript it&#039;s the function&#039;s duty to handle the given parameters and do something reasonable with unexpected types. The question arises: How do you write type safe functions in Javascript? Let me explain this by an example implementation to calculate the greatest common divisor of two numbers.&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/matthias-reuter/handling-the-unexpected-type-safe-functions-in-javascript&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/matthias-reuter/handling-the-unexpected-type-safe-functions-in-javascript&quot; dc:identifier=&quot;http://united-coders.com/matthias-reuter/handling-the-unexpected-type-safe-functions-in-javascript&quot; dc:title=&quot;Handling the unexpected - Type safe functions in Javascript&quot; trackback:ping=&quot;http://united-coders.com/trackback/34&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-1265&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/matthias-reuter/handling-the-unexpected-type-safe-functions-in-javascript#comments</comments>
 <category domain="http://united-coders.com/category/tags/function">function</category>
 <category domain="http://united-coders.com/category/tags/javascript">javascript</category>
 <category domain="http://united-coders.com/category/tags/jquery">jQuery</category>
 <category domain="http://united-coders.com/category/tags/types">types</category>
 <enclosure url="http://united-coders.com/sites/default/files/jquery.makeTypeSafe.js.txt" length="4662" type="text/plain" />
 <pubDate>Wed, 05 Aug 2009 10:11:59 +0000</pubDate>
 <dc:creator>Matthias Reuter</dc:creator>
 <guid isPermaLink="false">34 at http://united-coders.com</guid>
</item>
<item>
 <title>In-depth guide to javascript functions</title>
 <link>http://united-coders.com/christian-harms/in-depth-guide-to-javascript-functions</link>
 <description>&lt;!--paging_filter--&gt;&lt;p&gt;You already know how to define or assign functions directly, use multi parameter arguments in anonymous calls and know all the different variants of the function-constructor? Then you won&#039;t find anything new about the subtle differences in using functions in JavaScript.&lt;/p&gt;
&lt;p&gt;The work title of this article was &quot;Different ways to define JavaScript functions&quot;. Some code examples look quite similar but the differences can be important. While I am explaining the different ways to define JavaScript functions, you can test the code directly: install the &lt;a href=&quot;https://addons.mozilla.org/de/firefox/addon/1843&quot;&gt;firebug plugin&lt;/a&gt; and use the JavaScript console to play interactively below the article.&lt;/p&gt;
&lt;h2&gt;Function Statement&lt;/h2&gt;
&lt;p&gt;In the first example here I define a function to wrap the &quot;window.alert&quot;-function to open the default javascript popup-Message box:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;geshifilter&quot;&gt;&lt;div class=&quot;javascript geshifilter-javascript&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; hello&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&amp;nbsp; &lt;span style=&quot;color: #000066;&quot;&gt;alert&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&quot;font-family: monospace; font-weight: normal;&quot;&gt;&lt;div style=&quot;font-family: monospace; font-weight: normal; font-style: normal&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;read-more&quot;&gt;&lt;a href=&quot;/christian-harms/in-depth-guide-to-javascript-functions&quot;&gt;&lt;strong&gt;Read more&lt;/strong&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;!--
&lt;rdf:RDF xmlns:rdf=&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot; xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; xmlns:trackback=&quot;http://madskills.com/public/xml/rss/module/trackback/&quot;&gt;
&lt;rdf:Description rdf:about=&quot;http://united-coders.com/christian-harms/in-depth-guide-to-javascript-functions&quot; dc:identifier=&quot;http://united-coders.com/christian-harms/in-depth-guide-to-javascript-functions&quot; dc:title=&quot;In-depth guide to javascript functions&quot; trackback:ping=&quot;http://united-coders.com/trackback/21&quot; /&gt;
&lt;/rdf:RDF&gt;
--&gt;
&lt;div class=&#039;sexybookmarks-default-1039&#039;&gt;&lt;/div&gt;</description>
 <comments>http://united-coders.com/christian-harms/in-depth-guide-to-javascript-functions#comments</comments>
 <category domain="http://united-coders.com/category/tags/arguments">arguments</category>
 <category domain="http://united-coders.com/category/tags/callee">callee</category>
 <category domain="http://united-coders.com/category/tags/eval">eval</category>
 <category domain="http://united-coders.com/category/tags/function">function</category>
 <category domain="http://united-coders.com/category/tags/javascript">javascript</category>
 <pubDate>Wed, 06 May 2009 22:24:24 +0000</pubDate>
 <dc:creator>Christian Harms</dc:creator>
 <guid isPermaLink="false">21 at http://united-coders.com</guid>
</item>
</channel>
</rss>


