Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda