Jump to content

html dom forms object as array in js


ala888

Recommended Posts

There are certain data types called NodeList or HTMLCollection that the browser uses in the DOM, it can be accessed like if it was an array but it is an object. getElementsByTagName() and many other DOM methods also return a NodeList which behaves the same way.

 

You can't create objects like that using Javascript, it is something the browser does internally. Technically, the [] notation is not official, the specification says to use the item() method instead: document.getElementsByTagName("a").item(0);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...