title: Extract keys from JavaScript object and use as variables
body: <p>There is a method in PHP called <code>extract</code> which does exactly what I want to do here. Say I have an object that looks like this:</p>
  
  <pre><code>var data = {
      name: "Olly"
      age: 19
  };
  </code></pre>
  
  <p>I want to run a method like <code>extract(data)</code> so that I can then access the properties in that object by just using <code>name</code> and <code>age</code>, instead of <code>data.name</code> and <code>data.age</code>.</p>
  
  <p>I've done a bit of Googling and couldn't find anything.</p>