Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

217
Vistas
What is the best way to write functions that does not use its parameter in JS?

Specifically, I am using react-semantic-ui's Select Form, which takes an onChange function. So I have defined my function as such:

const handleInputChange = function handleInputChange(event, data){// does something with data}

(don't mind the ugly syntax, that's airbnb style guide)

I am doing something with data, but I am not using the event parameter at all. What would be the best practice in this case, since it is generally a bad practice to declare a variable without using it?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You must declare a parameter for every argument before the one you want to use.

The idiomatic approach to marking a parameter as unused is to prefix its name with an underscore.

function handleInputChange(_event, data){

Some linters will recognise this and not emit a "unused variable" warning.

For example ESLint has a argsIgnorePattern option (but it also has a args option that lets you specify after-used).

about 4 years ago · Juan Pablo Isaza Denunciar

0

Actually by using Js es6 you could code without unused argument:)

function handleInputChange(...[, data]) {
  console.log(data);
}

handleInputChange('event', 123);

And bellow is a similar question you could check out:) Standard conventions for indicating a function argument is unused in JavaScript

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda