ala888 Posted July 8, 2014 Share Posted July 8, 2014 if the html dom object forms exists in javascript as an object, why can its contents be called as if it were an array? documents.forms[0].... I appreciate the help! Link to comment Share on other sites More sharing options...
Ingolme Posted July 8, 2014 Share Posted July 8, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now