Retrieve by value from an Object?
<p>This <em>must</em> be a duplicate, but I've been Googling "retrieve by value from object javascript" and "javascript lookup object by value" and every variant and got nowhere, so apologies and here goes. </p>

<p>Say I have a JavaScript object like this:</p>

<pre><code>var options = {"ford": "red", "citroen": "blue"};
</code></pre>

<p>How do I do look up value <code>blue</code> to get <code>citroen</code> back?</p>

<p>There's always the 'write your own function' route, I guess:</p>

<pre><code>function returnbyValue(options, v):
    for (var prop in options) {
      if (options.hasOwnProperty(v)) {
        if (options[prop] === v) {
            return prop;
        }
      }
    }
    return null;
</code></pre>

<p>but does JavaScript have anything inbuilt, or is there a neater way to do this?</p>
