Checking if data is immutable
<p>What is the quickest and cleanest way to test if a <code>var</code> holds immutable data (i.e. is <code>string</code>, <code>number</code>, <code>boolean</code>, <code>null</code>, <code>undefined</code>)?</p>

<p>E.g. When <code>var test</code> is mutable, the following is legal:</p>

<pre><code>var test = {}; 
//the next 2 lines work because `test` has mutable data
test.someFun = function () { alert(this); };
test.someFun(); 
</code></pre>

<p>but when <code>var test</code> is immutable, it's illegal:</p>

<pre><code>var test = "string"; 
//the next 2 lines are invalid, as `test` is a primitive
test.someFun = function () { alert(this); };
test.someFun(); 
</code></pre>
