What is the correct JSDoc format for the array notation?
Array.<number>
or Array<number>
?
I've seen the two used interchangeably and do not know if there's a difference.
Also when it comes to Promise<number>
can I also use Promise.<number>
?
What is the correct JSDoc format for the array notation?
Array.<number>
or Array<number>
?
I've seen the two used interchangeably and do not know if there's a difference.
Also when it comes to Promise<number>
can I also use Promise.<number>
?
Closure compiler uses Array<number>
. It's possible other flavors of JSDocs prefer Array.<number>
, but I haven't worked with them.
eg:
/**
* 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