Getters/Setters and Documenting on MDN


(Jmedley) #1

I have an IDL for a new interface that specifies and indexed getter/setter. This basically means that an instance of the object has member that can be accessed in the same way as an array.

I don’t run into this very often. Can someone provide me with a link to another object whose members are accessed this way?

Thanks


(Eric Shepherd) #2

Sure.

See HTMLCollection, for example: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection (along with https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection/item).

Does that help?


(Jmedley) #3

I appreciate your help.


(Eric Shepherd) #4

HTMLCollection is definitely the best example I was able to find, or at least close to it. We probably could and should do a little better, and we definitely should write down how to do this properly in the contribution guide at some point, since this is a thing that happens from time to time and the answer is not obvious, clearly.