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

251
Views
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 answers
Answer question

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 Report

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 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!