Best way to document anonymous objects and functions with jsdoc

后端 未结 6 1165
北荒
北荒 2020-12-12 15:40

Edit: This is technically a 2 part question. I\'ve chosen the best answer that covers the question in general and linked to the answer that handles the specific question.

6条回答
  •  北海茫月
    2020-12-12 16:15

    You can use @callback or @typedef.

    /**
     * @callback arrayCallback
     * @param  {object} element - Value of array element
     * @param  {number} index   - Index of array element
     * @param  {Array}  array   - Array itself
     */
    
    /**
     * @param {arrayCallback} callback - function applied against elements
     * @return {Array} with elements transformed by callback
     */
    Array.prototype.map = function(callback) { ... }
    

提交回复
热议问题