Twitch Clips Twitch Clips - 6 months ago 58
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 = [];

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download