【问题标题】:Returning a object with specific property and type返回具有特定属性和类型的对象
【发布时间】:2015-10-21 05:58:49
【问题描述】:

我有一个函数operation,它接受两个参数str(一个字符串)和fn(一个函数)。

function operation(str, fn){
  var temp = {}
  temp[str] = fn
  return temp
}
  • 你如何描述这个返回值?
  • 这个返回值在 JSDoc 中是什么样的?
  • 示例输出格式是什么?

@return 描述可以接受吗?

@returns {Object} With one key set to str and one value set to fn.

@example 输出可以接受吗?

operation("foo", console.log)
// => {"foo": [Function]}

我问的主要原因是因为我想使用这种格式来测试像yamadapc/jsdoctest这样的套件中的功能。

【问题讨论】:

    标签: javascript types documentation jsdoc jsdoc3


    【解决方案1】:

    在我看来,你应该同时使用它们。例如,在 underscorejs 中,doc 被描述为 Fellow:

    【讨论】:

      猜你喜欢
      • 2022-01-01
      • 2016-09-16
      • 1970-01-01
      • 2014-08-11
      • 2022-11-02
      • 2019-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多