Why is var x = x = x || {} more thorough than var x = x || {}? : <p>In my endeavour to write clean Javascript code as a beginner, I was recently reading <a href="https://addyosmani.com/blog/essential-js-namespacing/" rel="noreferrer">this article</a> about namespacing in JavaScript when I stumbled upon this paragraph:</p>

<blockquote>
  <p>The code at the very top of the next sample demonstrates the different ways in which you can check to see if a variable (object namespace) already exists before defining it. You'll commonly see developers using Option 1, however Options 3 and 5 may be considered more thorough and Option 4 is considered a good best-practice.</p>

<pre><code>// This doesn't check for existence of 'myApplication' in
// the global namespace. Bad practice as you can easily
// clobber an existing variable/namespace with the same name
var myApplication = {};

/*
The following options *do* check for variable/namespace existence.
If already defined, we use that instance, otherwise we assign a new
object literal to myApplication.

Option 1: var myApplication = myApplication || {};
Option 2  if(!MyApplication) MyApplication = {};
Option 3: var myApplication = myApplication = myApplication || {}
Option 4: myApplication || (myApplication = {});
Option 5: var myApplication = myApplication === undefined ? {} : myApplication;

*/
</code></pre>
</blockquote>

<p><strong>Option 1</strong> is certainly the one I have seen used most of the time, and I understand it well.</p>

<p><strong>Option 2</strong> is fine but seems to lack a <code>var myApplication</code> beforehand or a <code>if(!window.myApplication)</code> otherwise if <code>myApplication</code> is not in the global scope the condition <code>if(!myApplication)</code> would throw an error, wouldn't it?</p>

<p><strong>Option 3</strong> is the one I have trouble with: my understanding is that the <code>myApplication = myApplication</code> is executed first, with <code>myApplication</code> in the global scope (due to the <code>var</code> at the begining). My problem is that I can't think of a case where this option does anything more than option 1.</p>

<p><strong>Option 4</strong> in my eyes would have been better written <code>window.myApplication || (myApplication = {})</code> to avoid throwing an error if <code>myApplication</code> is not in the global scope.</p>

<p><strong>Option 5</strong> is excluding the false-y values other than <code>undefined</code> but is it a good idea? If <code>myApplication</code> is say an empty string, the rest of the code is likely to fail, isn't it?</p>

<p>Would someone be able to shed some light on the differences between the different options and in particular explain why option 3 is described as more thorough?</p>
