<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Closures on Coderrob</title><link>https://coderrob.com/tags/closures/</link><description>Recent content in Closures on Coderrob</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 27 Apr 2026 10:00:00 -0500</lastBuildDate><atom:link href="https://coderrob.com/tags/closures/index.xml" rel="self" type="application/rss+xml"/><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></channel></rss>