javascript push returning number instead of object [duplicate]

Array#push method works in situ, you don’t have to assign it to a new variable. It won’t return a new array, but will modify the original one and will return it’s length. That’s why you are getting 3 as the result.

To get the desired result, just call it, without assigning to any variable:

reminders.push(newReminder);

Leave a Comment