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