首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Array.<number>还是Array<number>?

Array.<number>还是Array<number>?
EN

Stack Overflow用户
提问于 2019-03-14 01:47:14
回答 1查看 120关注 0票数 1

数组表示法的正确JSDoc格式是什么?

Array.<number>Array<number>

我见过这两个词可以互换使用,不知道是否有区别。

另外,当涉及到Promise<number>时,我可以使用Promise.<number>

EN

回答 1

Stack Overflow用户

发布于 2019-03-14 05:27:42

闭包编译器使用Array<number>。可能其他风格的JSDocs更喜欢Array.<number>,但我还没有用过它们。

例如:

代码语言:javascript
复制
/**
 * Sorts an array of objects by the specified object key and compare
 * function. If no compare function is provided, the key values are
 * compared in ascending order using <code>goog.array.defaultCompare</code>.
 * This won't work for keys that get renamed by the compiler. So use
 * {'foo': 1, 'bar': 2} rather than {foo: 1, bar: 2}.
 * @param {Array<Object>} arr An array of objects to sort.
 * @param {string} key The object key to sort by.
 * @param {Function=} opt_compareFn The function to use to compare key
 *     values.
 */
goog.array.sortObjectsByKey = function(arr, key, opt_compareFn) {
  goog.array.sortByKey(arr, function(obj) { return obj[key]; }, opt_compareFn);
};

Via - https://github.com/google/closure-library/blob/master/closure/goog/array/array.js#L1194

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55148271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档