var object = {
}
socket.on('call', function(data){
console.log(data); // On console: { number: 68, name: 'John' }
object.push(data);
});
In the console.log I get the object just fine. But the push function doesn't seem to be working.
object.push(data);
^
TypeError: object.push is not a function
arraynot forobjectpushis a member function ofArray, notObject. You can't "push" anything into an object. Tryvar arr = []; ... arr.push(data);;