UseJSDoc.org @type page explains how to document arrays and objects, but not arrays of objects. My function accepts an array of objects with a specific list of properties, and these are the properties that I would like to document.
The function may look like function foo(people) , and the people array could be created by the calling element of the function as
arr = []; arr.push({name: "Alfred", profession: "Butler", hitpoints: 2}); arr.push({name: "Batman", profession: "Vigilante", hitpoints: 42}); // ... foo(arr)
I would like to use the syntax {{name: string, profession: string, hitpoints: number}} Person to document objects, but also include the idea that they should be in an array.
Please note that the main object (what I call Person above, although the code will not reference anything like that) is not a proper class, not even named anywhere. And not a single " Person " is defined to use the @ tag.
This complexity of documenting such code with JSDoc3 may seem like a poor organization, and I will gladly consider tips on how to reorganize such ephemeral objects that are primarily used as hash tables (associative arrays).
javascript object arrays jsdoc jsdoc3
Ahmed fasih
source share