Chris
Chris

Reputation: 368

Socket.io - is using multiple function arguments bad practice?

I'm new to socket.io and have noticed that in general when multiple parameters need to be sent, they are sent in a single object. (socket.emit('message name', {arg1: ..., arg2: ...}))

However, I have also noticed that passing multiple arguments in the function appears to work. (socket.emit('message name', arg1, arg2))

Is there any disadvantage of emitting messages with multiple arguments?

Upvotes: 0

Views: 157

Answers (1)

Matthew Powell
Matthew Powell

Reputation: 122

There is no disadvantage to using either option. It's just a matter of preference. Both are supported in the Socket.io documentation

Upvotes: 1

Related Questions