title: LINQ SingleOrDefault() equivalent
body: <p>In Typescript, I use this pattern often:</p>
  
  <pre><code>class Vegetable {
      constructor(public id: number, public name: string) {
      }
  }
  
  var vegetable_array = new Array&lt;Vegetable&gt;();
  vegetable_array.push(new Vegetable(1, "Carrot"));
  vegetable_array.push(new Vegetable(2, "Bean"));
  vegetable_array.push(new Vegetable(3, "Peas"));
  
  var id = 1;
  var collection = vegetable_array.filter( xvegetable =&gt; {
      return xvegetable.id == id;
  });
  var item = collection.length &lt; 1 ? null : collection[0];
  
  console.info( item.name );
  </code></pre>
  
  <p>I am thinking about creating a JavaScript extension similar to the LINQ <a href="https://msdn.microsoft.com/en-us/library/bb549274" rel="noreferrer"><code>SingleOrDefault</code></a> method where it returns <code>null</code> if it's not in the array:</p>
  
  <pre><code>var item = vegetable.singleOrDefault( xvegetable =&gt; {
      return xvegetable.id == id});
  </code></pre>
  
  <p>My question is whether there is another way to achieve this without creating a custom interface?</p>