0

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]);

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.