Twitch Clips Twitch Clips - 27 days ago 6
Node.js Question

object.push is not a function [Node/]

var object = {


socket.on('call', function(data){
console.log(data); // On console: { number: 68, name: 'John' }

In the console.log I get the object just fine. But the push function doesn't seem to be working.

TypeError: object.push is not a function

Answer Source

object here is an Object, so not have the push function.

If you want to use an object use object[key] = value; or object.key = value;

Array.push in others hand exists.

var object = [];