How to get last item from array of object? : <p>I have JSON object from server and requirement is to always display last item from the array <code>items</code>. how can i achieve that task using AngularJs or native JavaScript ?</p>

<p>Below case i have to display text <code>Chief Administrative Officer</code>.</p>

<p>main.js</p>

<pre><code>  angular.forEach($scope.rcsaErhTreeData, function(val) {
      angular.forEach(val, function(val) {
          console.log('this is the array value', val[0].text);
      });
  });
</code></pre>

<p>json.js</p>

<pre><code>[{
    "uid": null,
    "index": 0,
    "selected": null,
    "expanded": null,
    "id": 2701,
    "text": "BAC Enterprise Wide",
    "parentId": 0,
    "items": [{
        "uid": null,
        "index": 0,
        "selected": null,
        "expanded": null,
        "id": 4114,
        "text": "Chief Administrative Officer",
        "parentId": 2701,
        "items": []
    }]
}]
</code></pre>
