0

socket.emit(eventName[, ...args][, ack])

Hello everyone. I just had a simple question. When I'm reading through documentation. The thing I find a little confusing is what certain things mean. So I know if you have something like [, ack]. That means it's optional but what about [, ...args]. I'm guessing it means it's optional too and you can specify more than one argument but I'm not sure? If anyone could help me out and link me a good wiki/resource about understanding documentation or explain it. I'll gladly appreciate it.

yuriy636
  • 11,171
  • 5
  • 37
  • 42
  • yes, you are right – Jonas Wilms Dec 28 '17 at 09:56
  • 1
    @SergioTulentsev This is not the spread operator. – Serge K. Dec 28 '17 at 10:04
  • @SergeK. Hm, you're right. What is this called in function signature then? In ruby, for example, both directions of the same thing are called "splat", defining (`def foo(*args)`) and calling (`foo(*args)`). I assumed here it's the same. – Sergio Tulentsev Dec 28 '17 at 10:05
  • @SergeK.: also it appears that I misread the line. It's not an actual code. Oh well, I shall go back to what I know :) – Sergio Tulentsev Dec 28 '17 at 10:12
  • @SergeK.: still, what is the name of the operator in `function foo(...args)`? – Sergio Tulentsev Dec 28 '17 at 10:14
  • 1
    @SergioTulentsev Yes this comes from the documentation :) It is called [the rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters), I looked it up on the documentation I didn't knew it. – Serge K. Dec 28 '17 at 10:22
  • 1
    Ty guys. I got it now. I knew it was a rest parameter but when I asked the question. I was mainly just wondering if there was some sort of wiki/resource online I could read that goes over what certain things in the documentation. For example. If you have something like [, callback]. That means it's an optional parameter. If you have something like "[color] | [size]". That means either one of them would work. –  Dec 28 '17 at 10:31

0 Answers0