3

Where can i find a list of all available methods on variables in Javascript?

Eg:

var Variable1 = document.getElementById("Button1");
var Variable2 = document.getElementById("Label1");
var Variable3 = document.getElementById("TextBox1");

What are the properties of Variable1, Variable2 and Variable3?

Are they the same even though Variable1 is a Button element, Variable2 is a Label element and Variable3 is a TextBox element?

4 Answers 4

4

Aside from Dredel's answer, you can also log in your console the available properties, and methods of the object by using console.dir(document.getElementById('idhere'));, or variations thereof.

Sign up to request clarification or add additional context in comments.

1 Comment

I was able to use your suggestion as well Daedalus.
2

you can do a for(var a in obj) and get a list of everything that the object has in it. In your case for(a in Variable1) will reveal all the objects. You can then look at them (in the loop) via Variable1[a]

And they will be largely the same, assuming they're part of the DOM cause DOM objects all inherit from the same display object, but no, they won't be identical since certain HTML objects have unique properties that aren't shared globally. Be prepared for a LONG list!

1 Comment

Thanks @Dredel.. I got the LONG list..!
2

MDN is a good reference. Begin with Node and Element, from which pretty much every HTML element will inherit.

Another good way to learn that are the DOM references: HTML Level 2 IDL and JavaScript definitions.

There are also some other definitions at the HTML5 standard itself.

Comments

0

In modern browsers you can use

Object.getOwnPropertyNames(variable1)

This will return only own properties, not inherited ones. If you want all of them use for (var property in obj) ....

Elements all inherit from the same objects, so they mostly have the same properties; you'll find differences like .checked, .multiple, etc.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.