title: Check whether a value exists in JSON object
body: <p>I have the next JSON:
  </p>
  
  <pre><code>var JSONObject = {"animals": [{name:"cat"}, {name:"dog"}]};
  </code></pre>
  
  <p>What is the best way to know if the "dog" value exists in the JSON object?</p>
  
  <p>Thanks.</p>
  
  <p><strong>Solution 1</strong></p>
  
  <pre><code>var JSONObject = {"animals": [{name:"cat"}, {name:"dog"}]};
  ...
  for (i=0; i &lt; JSONObject.animals.length; i++) {
      if (JSONObject.animals[i].name == "dog")
          return true;
  }
  return false;
  </code></pre>
  
  <p><strong>Solution 2 (JQuery)</strong></p>
  
  <pre><code>var JSONObject = {"animals": [{name:"cat"}, {name:"dog"}]};
  ...
  $.map(JSONObject.animals, function(elem, index) {
   if (elem.name == "dog") 
       return true;
  });
  return false;
  </code></pre>
  
  <p><strong>Solution 3 (using some() method)</strong></p>
  
  <pre><code>function _isContains(json, value) {
      let contains = false;
      Object.keys(json).some(key =&gt; {
          contains = typeof json[key] === 'object' ? 
          _isContains(json[key], value) : json[key] === value;
          return contains;
      });
      return contains;
  }
  </code></pre>