In "prototypes" I have used the Element.prototype
and HTMLElement.prototype
several times. I wanted to know what each one is and what the difference between them is, if possible. Because in some tests, like these, I had the same result:
HTMLElement.prototype.tooltip(); // funciona com um elemento normalmente
Element.prototype.tooltip(); // funciona com o mesmo elemento normalmente
Could someone show me the practical difference between the two, if not some concept or specification.
Another question that is while at NodeList.prototype
, I know so far that I can use it for, for example, document.querySelectorAll('elemento')
. But I think I'd have to use forEach
and apply an already existing prototype
, like this:
HTMLElement.prototype.tooltip = function(){
...
}
NodeList.prototype.tooltip = function(){
[].forEach.call(NodeList, function(el){ // O NodeList dessa Linha, como usá-lo?
el.tooltip() // tooltip já criado para elementos em particulares
})
}
I am trying to use forEach
as an Array, I could also use NodeList
, but what I pass as a parameter instead of the "NodeList", Array.from()
does not work ...
Thank you in advance.