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

252
Vistas
How to docstring a function arugument which is itself a function with arguments in JavaScript?

How can I docstring an argument which is a function itself?

Example:

/**
 * 
 * @param secondFunction // I want to say this should be a function that accepts a number
 */
function firstFunction(secondFunction) {
    const a = 1;
    secondFunction(a);
}

Cheers!

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

0

You can define the type of the parameter to be the function signature you expect to be passed:

/** Calls second function with 1
 * @param {(a:number)=>void} secondFunction
 */
function firstFunction(secondFunction) {
    const a = 1;
    secondFunction(a);
};
about 4 years ago · Juan Pablo Isaza Denunciar

0

From the JSDoc documentation:

Callback functions

If a parameter accepts a callback function, you can use the @callback tag to define a callback type, then include the callback type in the @param tag.

Parameters that accept a callback

/**
 * This callback type is called `secondFunction` and is displayed as a global symbol.
 *
 * @callback secondFunction
 * @param {number} a
 */

/**
 * executes secondFunction
 * @param {secondFunction} secondFunction - The callback
 */
function firstFunction(secondFunction) {
    const a = 1;
    secondFunction(a);
};
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