title: What to use javascript array or object or mix of them?
body: <p>I need a javascript array or object or maybe something mixed for this task:</p>
  
  <p>I have this attributes:
  customer
  item
  barcode </p>
  
  <pre><code>So I will fill all fields with loop like this:
  customer = 1
  item = 1
  barcode = 5555
  
  customer = 1
  item = 2 
  barcode = 6666
  </code></pre>
  
  <p>the combination of customer and item will be unique, so I want to directly access the value (barcode), like this:</p>
  
  <p>"give me the barcode value where customer = 1 and item 1, so the result must be 5555"</p>
  
  <p>I don't want to use loop to find the value, I want direct access.</p>
  
  <p>Thanks!</p>
  
  <p>Currently, I have created example script. My question is there anything better?</p>
  
  <pre><code>function cacheBarcodes() {
      var results = [];
      // Here the database is pushing all 100k+ records to the array
      results.push(['1', '1', '5555']);
      results.push(['1', '2', '6666']);
  
      return results;
  }
  
  function getBarcode(results,customer,item) {
  
      for (var i = 0; i &lt; results.length; i++) {
          var db_customer = results[i][0];
          var db_item = results[i][1];
          var db_barcode = results[i][2];
  
          if (db_customer == customer &amp;&amp; db_item == item ) {
              return db_barcode;
          }
      }
  
  }
  results = cacheBarcodes();
  alert(getBarcode(results,'1','1'));
  </code></pre>