document.scripts
returns an HTMLCollection
object holding a list of all scripts in a document. Similarly, document.getElementsByTagName("script")
returns another HTMLCollection
object holding a list of all scripts in the document.
I expected the following statement to be true however it's not.
document.scripts === document.getElementsByTagName("script") // false
What is the reason for both these not being equal?
Here's an example where they give different results. document.scripts returns the set of HTMLElement scripts, where getElementsByTagName("script") returns the set of all scriot elements regardless of namespace.
(The StackSnippets logic adds two script elements to the document beyond those shown in the example code here.)