title: Angular2 using .filter() to get index and object from array?
body: <p>Is there any way to make the following code simpler?</p>
  
  <pre><code>let objectModified = this.objectsModified.filter(objectModified =&gt; {
    if(objectModified.index === this.objectCurrent.index) {
      return objectModified;
    }
  })[0]; /*[0] because there is no way the could be .length &gt; 1 */
  
  if(objectModified) {
    let index = this.objectsModified.indexOf(objectModified);
    this.objectsModified[index] = "something";
  }
  
  else {
    this.objectsModified.push("something");
  }
  </code></pre>
  
  <p>It seems to me that there must be a smarter, more readable solution. But I can't figure it out.</p>