I'm receiving this error when I try to start node:
console.dir({socket.id:data});
^
Why?
I'm receiving this error when I try to start node:
console.dir({socket.id:data});
^
Why?
You cannot use a .
in object key's names. If you really want to do this, use
{ 'socket.id' : data }
When using JSON to describe an object, the key names must directly translate to a string literal (as in, not refer to other variable identifiers). If you want another object's value to be the key name of the variable, you may try this:
var o = {};
o[socket.id] = data;
console.dir(o);