title: Javascript if a value exists in an object?
body: <p>ive got an object:</p>
  
  <pre><code>var car = {
      company: "Honda",
      year: "2011",
      Model: "Brio"
  }
  </code></pre>
  
  <p>I was wondering if there exists an inherited method (is that the right phrase?) to check if a value exists inside a given object, somewhat like <code>x.hasOwnProperty</code>, or <code>if (x in car)</code>. Or, should I write my own.</p>
  
  <p>I've done a few google searches, but they all either lead to <code>hasOwnProperty</code> or to check if a value exists inside an array.</p>
  
  <p>Editing to please all the people in the comments:
  There are two use cases i could think of where this would be useful:</p>
  
  <ol>
  <li><p>checking for undefined keys and reporting which one</p>
  
  <pre><code>if (!car.isInvalid(car, undefined)) 
      validCarsArray.push (car);
  </code></pre></li>
  <li><p>Checking if a general user input exists in an object</p>
  
  <pre><code>var text = searchBox.input; 
  
  validCarArrays.forEach (function (car) {
      if (car.hasOwnValue(car, text)) {
      displayToUserAsResult (car);
      }
  });
  </code></pre></li>
  </ol>