title: What is the size of objects in JavaScript?
body: <p>Lets consider an example of programming language <strong>C</strong>. There are multiple data types in <strong>C</strong> like <code>int</code>, <code>short</code>, <code>char</code> etc. All of those data types has a specific disk size allocated to them. For eg. <code>char</code> has a pre-specified size of 1 byte, <code>short</code> has a size of 2 bytes and so on.</p>
  
  <p>As, in JavaScript everything is an object, how you determine the size of an object (an array or string or number etc.)?</p>
  
  <p>Just to understand my question here is a sample:</p>
  
  <pre><code>var array1 = [10, 20, 30];
  var array2 = [];
  var string1 = '';
  var string2 = 'some value';
  </code></pre>
  
  <p>If we check the <code>typeof</code> of anything above it returns <code>object</code>. Now, I'm not able to understand how it allocates size to an object and what will be the exact amount of size allocated (because everything is an object and some objects my have big values, some might be empty, some might have very small values). </p>