Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
Simple questions on javasript: socket.io and arrow function method () => {}

I'm currently studying basic javascript features, and I am quite struggling with the arrow function method. So I from what I've learnt, if there is only one parameter, it doesn't matter if we use parenthesis or not like the code below:

(singleParam) => { statements }
singleParam => { statements }

Then when emitting events in socket IO, to simplify the codes

// server-side
io.on("connection", (socket) => {
  socket.emit("hello", "world");
});

// client-side
socket.on("hello", (arg) => {
  console.log(arg); // world
});

could be simplified as

// server-side
io.on("connection", socket => {
  socket.emit("hello", "world");
});

// client-side
socket.on("hello", arg => {
  console.log(arg); // world
});

This is working fine in my project, thus I wonder the necessity of using parenthesis when using arrow method function. Maybe I'm not fully grasping the concepts, can anyone explain this method a little bit easier way? Thanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If using exactly one parameter in an arrow function you don't need to use the parenthesis. Some developers prefer to always add them however for consistency and readability.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!