O
O
OWIII2020-11-14 16:09:28
JavaScript
OWIII, 2020-11-14 16:09:28

Array.push method what is the problem?

Hi all. Whether I overheated already, in general, something incomprehensible.
Who can advise? Why can't I add a new object to an array of objects using the push method?
Why is it showing me a number in the console?

const errors = [
  {
    isEmptyError: false,
    textError: ''
  },
  {
    minLengthError: false,
    textError: '',
  },
];

const newArray = errors.push({
  minLengthError: false,
  textError: 'Something',
});

console.log(newArray)


https://jsbin.com/mezabeyuwo/1/edit?html,js,console

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Gordinskiy, 2020-11-14
@OWIII

The push() method adds one or more elements to the end of an array and returns the new length of the array.

Have you tried reading the documentation before using the methods?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question