title: Object destructuring without var, let or const
body: <p>Why does object destructuring throw an error if there is no <code>var</code> keyword in front of it?</p>
  
  <pre><code>{a, b} = {a: 1, b: 2};
  </code></pre>
  
  <p>throws <code>SyntaxError: expected expression, got '='</code></p>
  
  <p>The following three examples work without problems</p>
  
  <pre><code>var {a, b} = {a: 1, b: 2};
  var [c, d] = [1, 2];
      [e, f] = [1, 2];
  </code></pre>
  
  <p>Bonus question: Why do we not need a <code>var</code> for array destructuring?</p>
  
  <p>I ran into the problem doing something like</p>
  
  <pre><code>function () {
    var {a, b} = objectReturningFunction();
  
    // Now a and b are local variables in the function, right?
    // So why can't I assign values to them?
  
    {a, b} = objectReturningFunction();
  }
  </code></pre>