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

155
Visualizações
Inquiry to write function to javascript Object JSDoc property

I need to put a function in a javascript object, how do I add a JSDoc comment in this case?

/**
 * @typedef {Object} testObj
 * @property {!String} testName - testName
 * @property {?Function} [testFunction=null] - testFunction
 *
 */
var testObj = {
    testName:null,
    testFunction:null
}

In this form, null is the default value for the function, so it is expressed like this.

I just want to ask if it is enough to write only the @property {?Function} and write the parameter in the Object part, or if there is another way.

In the testFunction above, I want to show in JSDoc that a function with parameters {Number} a, {number} b, {Object} c is put in. If there is a way, I would appreciate it if you let me know. And I also want to express that this function returns a String.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Use @function to define the function first, and then use the name of the function anywhere you need it, example:

/**
 * A test function
 *
 * @function testFunction
 * @param  {number} a Number a
 * @param  {number} b Number b
 * @param  {Object} c Object c
 * @returns {string} Returns a string
 */

/**
 * A test Object
 *
 * @typedef {Object} testObj
 * @property {!string} testName The Test Name
 * @property {?testFunction} testFunction The Test Function
 */
const testObj = {
  testName: null,
  testFunction: null,
}

Just tested it with jsdoc and the documentation is generated correctly with the link in the testFunction property.

enter image description here

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