开发者

Why the naming: NodeList vs childNodes

I have been wondering about a stupid thing about the DOM. Why do the standards define NodeList with the postfix List to make it clear it is an a开发者_JS百科rray while have a some properties or functions like childNodes or getElementsByTagName which use the postfix letter s?

I find it contradictory when the standards define members with different suffixes for the same purpose (to describe an array).

Edit: It actually seems that NodeList is not even an array. Does this explain this?


NodeList is an interface.

childNodes is a member of the Node interface.
getElementsByTagName is a member of the Document interface.

BTW, both these members return a value of type NodeList.

So, there is a difference: one is an interface, and the other two are members of interfaces.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜