<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Functions on Coderrob</title><link>https://coderrob.com/tags/functions/</link><description>Recent content in Functions on Coderrob</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 27 Apr 2026 11:30:00 -0500</lastBuildDate><atom:link href="https://coderrob.com/tags/functions/index.xml" rel="self" type="application/rss+xml"/><item><title>JavaScript Arrow Functions Explained</title><link>https://coderrob.com/posts/javascript-arrow-functions-explained/</link><pubDate>Mon, 27 Apr 2026 11:30:00 -0500</pubDate><guid>https://coderrob.com/posts/javascript-arrow-functions-explained/</guid><description>&lt;p&gt;Arrow functions are compact JavaScript functions with a few deliberate differences from ordinary functions.&lt;/p&gt;
&lt;p&gt;They are excellent for small transformations and callbacks. They are not a universal replacement for &lt;code&gt;function&lt;/code&gt;, and treating them like one hides the exact behavior that makes them useful.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Use an arrow when you want a concise function and do not need the function to define its own &lt;code&gt;this&lt;/code&gt;, &lt;code&gt;arguments&lt;/code&gt;, or constructor behavior.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id="the-basic-syntax"&gt;The Basic Syntax&lt;/h2&gt;
&lt;p&gt;An ordinary function expression looks like this:&lt;/p&gt;</description></item><item><title>JavaScript 'this' Explained</title><link>https://coderrob.com/posts/javascript-this-explained/</link><pubDate>Mon, 27 Apr 2026 11:00:00 -0500</pubDate><guid>https://coderrob.com/posts/javascript-this-explained/</guid><description>&lt;p&gt;JavaScript&amp;rsquo;s &lt;code&gt;this&lt;/code&gt; is not difficult because it does many things. It is difficult because one small word changes value based on &lt;strong&gt;how a function is called&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;That makes &lt;code&gt;this&lt;/code&gt; look unpredictable when the real problem is usually that we are looking in the wrong place.&lt;/p&gt;
&lt;p&gt;For an ordinary function, do not start with where the function was written. Start with the call-site.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;The call usually decides &lt;code&gt;this&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That one rule explains most of the behavior you will meet in day-to-day JavaScript.&lt;/p&gt;</description></item><item><title>JavaScript Closures and Modified Closures Explained</title><link>https://coderrob.com/posts/javascript-closures-and-modified-closures-explained/</link><pubDate>Mon, 27 Apr 2026 10:00:00 -0500</pubDate><guid>https://coderrob.com/posts/javascript-closures-and-modified-closures-explained/</guid><description>&lt;p&gt;Closures show up any time a JavaScript function uses a variable defined from outside its own curly braces.&lt;/p&gt;
&lt;p&gt;That makes them common in callbacks, event handlers, timers, factory functions, and plenty of code that passes functions around.&lt;/p&gt;
&lt;p&gt;This post is about two questions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;What is a closure?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;What happens when a closed-over variable is modified before the function uses it?&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The short version:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A closure happens when a function keeps access to variables from its surrounding scope, even after that outer scope has finished running.&lt;/p&gt;</description></item><item><title>JavaScript Function Parameters and Arguments Explained</title><link>https://coderrob.com/posts/javascript-function-parameters-and-arguments-explained/</link><pubDate>Thu, 17 Sep 2020 00:46:15 -0500</pubDate><guid>https://coderrob.com/posts/javascript-function-parameters-and-arguments-explained/</guid><description>&lt;h2 id="javascript-function-signatures"&gt;JavaScript Function Signatures&lt;/h2&gt;
&lt;p&gt;Alright, you&amp;rsquo;ve probably seen functions before. Something like this maybe?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#000;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f00"&gt;function&lt;/span&gt; doSomething(name, desc, task) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#0f0"&gt;// did something
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This function, named &lt;code&gt;doSomething&lt;/code&gt;, takes three &lt;code&gt;parameters&lt;/code&gt; as part of its function signature. These parameters named &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;desc&lt;/code&gt;, and &lt;code&gt;task&lt;/code&gt; are the names of the values being sent into the function.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m going to use a sportsball reference here so be warned. You can think of the function as a net that gets various types of objects tossed into the hoop &lt;code&gt;( )&lt;/code&gt; where it triggers sports points.&lt;/p&gt;</description></item></channel></rss>