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
Is it necessary to include the argument in the callback function of Promise.prototype.catch()?

Background

According to the MDN docs, Promise.prototype.catch() takes a parameter called onRejected, which is a function that is called when the Promise is rejected. (Internally, this calls Promise.prototype.then(undefined, onRejected).)

According to the docs, onRejected “has” one parameter, reason, which is the rejection reason. In the examples given, this parameter is always present.

E.g.,

p.catch(function(e) {
  console.error(e);
})

Question

I am writing code where I do not want to use the reason parameter, so something like this:

p.catch(function(e) {
  foo();
})

Is it better practice to leave in the e parameter, since according to the docs onRejected is supposed to have it? (ESLint will also complain about this).

Or is it common practice to remove it? As in

p.catch(function() {
  foo();
})

PS: I know about optional catch binding, but that is for try-catch blocks.

about 4 years ago · Juan Pablo Isaza
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