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

187
Views
Why is this function in Javascript executed when the parameters are different?

I've come across this code and not sure why X works here.

function event() {
  var eventS = 'triathlon';
  eventOfTheDay(eventS);
}

function eventOfTheDay(x) {
  return console.log('You set a reminder about ' + x);
}
event();

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

The one and only thing about functions in a programming language is that the parameter name can be any proper variable name according to its language's convention, and it is not mandatory to be the same variable name that you have used in your calling function.

A simple example:

You give some "thing" to your friend. You call it as "X" and your friend can call it as "Y". The thing is same. Its just the name that you and your friend are using according to your wish. The same is with functions :)

In your example, you are passing 'triathlon'. You call it as eventS (Maybe you like to use it as eventS there because it makes sense there), and your friend (eventOfTheDay) calls it as x, or y or anything he wishes to (Because that new name can make sense there).

about 4 years ago · Santiago Gelvez 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!