I want to document a new method to an internal Array objects, so that I can use the method everytime I make an array. For example:
/**
* @<whatsInHere?> Array
* @returns {number}
*/
Array.prototype.avg = function () {
let sum = 0;
for (let _x = 0; _x < this.length; _x++) sum += this[_x];
return sum / this.length;
}
const myArray = [3,4,5,6,34,5,2];
const average = myArray.avg();
What should I do to document avg?
Thank you;
UPDATE: I've found about @external here and modified mine like this:
/**
* @external Array
*/
/**
* @functions external:Array#avg
*
*/
Array.prototype.avg = function() {}
Did not work either. Or perhaps, I use it the wrong way?