title: How can I create all combinations of this object's keys/values in JavaScript?
body: <p>I have the following JavaScript object structure:</p>
  
  <pre><code>var options = {
      optionOne: [true, false],
      optionTwo: [true, false],
      optionThree: [
          null,
          {property1: 9, property2: 7},
          {property1: 4, property2: 12},
          {property1: 16, property2: 14}
      ]
  };
  </code></pre>
  
  <p>Please note that the number of key/pairs in this object will differ. So there might actually be <code>optionFour</code>, <code>optionFive</code>, etc., and each option can have any number or type of values for its array.</p>
  
  <p>I need to iterate through this object and create an array containing objects of all possible option combinations:</p>
  
  <pre><code>[
      {optionOne: true,  optionTwo, true,  optionThree: null},
      {optionOne: false, optionTwo, true,  optionThree: null},
      {optionOne: true,  optionTwo, false, optionThree: null},
      {optionOne: false, optionTwo, false, optionThree: null},
      {optionOne: true,  optionTwo, true,  optionThree: {property1: 9, property2: 7}},
      {optionOne: false, optionTwo, true,  optionThree: {property1: 9, property2: 7}},
      {optionOne: true,  optionTwo, false, optionThree: {property1: 9, property2: 7}},
      {optionOne: false, optionTwo, false, optionThree: {property1: 9, property2: 7}},
      {optionOne: true,  optionTwo, true,  optionThree: {property1: 4, property2: 12}},
      {optionOne: false, optionTwo, true,  optionThree: {property1: 4, property2: 12}},
      {optionOne: true,  optionTwo, false, optionThree: {property1: 4, property2: 12}},
      {optionOne: false, optionTwo, false, optionThree: {property1: 4, property2: 12}},
      {optionOne: true,  optionTwo, true,  optionThree: {property1: 16, property2: 14}},
      {optionOne: false, optionTwo, true,  optionThree: {property1: 16, property2: 14}},
      {optionOne: true,  optionTwo, false, optionThree: {property1: 16, property2: 14}},
      {optionOne: false, optionTwo, false, optionThree: {property1: 16, property2: 14}}
  ]
  </code></pre>
  
  <p>I'm struggling on how to accomplish this but am fairly confident the answer lies in recursion.</p>
  
  <p>Can the algorithm gods help me?</p>