title: Get last element of a JSON array in TypeScript
body: <p>I need to get the value of the "id" property of the last element in array of JSON objects. I can find each element by id but I also need to get the value of last "id" in the array of JSON objects. In the example below it is '3'. Thanks in advance!</p>
  
  <pre><code>let types: any[] =
      [
          {'id': '0', 'value': ''},
          { 'id': '1', 'value': '' },
          { 'id': '2', 'value': '' },
          { 'id': '3', 'value': '' },
      ]; 
  
  let index = 0;
  let indexNext = 1;
  types.forEach((item) =&gt; { 
      if (item.id == index) { 
          item.value = 'Book';
          console.log(item.value); //Book
      }
      if (item.id == indexNext) { 
          item.value = 'Magazine';
          console.log(item.value); //Magazine
      }
  })
  </code></pre>