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

129
Views
Extra parameters in a self executing function?

I saw this piece of code in a webpack compiled file

(1,2, function(x) {
    console.log(x);
    return 4;
})(5);

This seems to execute correctly. I am aware the 5 is a parameter to function(x)

I don't understand what the 1,2 are? How is this valid?

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

0

Well, it's because the brackets only returns the function

(thing1,thing2,thing3,thing4....,thingN) would show the last thing on the list(in this case, thingN)

Example

var bracketTest1=(1,3,5,7,9,null)
console.log(bracketTest1) //null
var bracketTest2=(null,1,2,3,4)
console.log(bracketTest2) //4
var bracketTest3=(null,1,2,4,5,function(x){return x})
console.log(bracketTest3) //function(x)
console.log(bracketTest3(Object)) //function Object()
console.log((1,2,3,4,null,undefined)) //prints undefined

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!