is it possible to loop through all objects?

B

Bryan

If you have a javascript interpreter running in an environment unknown
to you (as in what objects it exposes to the language) is it possible
to loop through all objects in some way?

This is a non-browser environment, specifically the scripting engine
for doing xslt extensions in msxml.
 
L

Lasse Reichstein Nielsen

If you have a javascript interpreter running in an environment unknown
to you (as in what objects it exposes to the language) is it possible
to loop through all objects in some way?

Only by brute-force exhaustive search. I.e., no.

Javascript allows you to find only some of the properties of objects,
those that are enumerable. You find them using
for (var propName in object) { ... }
Those that are not enumerable cannot be seen except by knowing their
name. One example is Object.prototype.toString. You know it is there,
but if you didn't know its name, you wouldn't be able to find it except
by trying all strings as property names and see if they exist. Since
there are infintly many strings, that won't work. Restricting to only those
of, say, 32 letters or below, will make it a finite problem. Sadly,
the universe is probably also final, and could end before you finish :)
This is a non-browser environment, specifically the scripting engine
for doing xslt extensions in msxml.

That depends on that specific environment. If none of the properties it
adds are non-enumerable, then you can find them. Otherwise, you can't.

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top