Reputation: 43
I would like to add data to array. But I want to push start always messages[0] , and shouldnt lost messages datas
this.messages.push(data[0]);
Upvotes: 0
Views: 1019
Reputation: 13416
you want unshift(). push() adds to the end of an array while unshift adds to the beginning (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift)
this.messages.unshift(data);
Upvotes: 1