By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,727 Members | 1,391 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,727 IT Pros & Developers. It's quick & easy.

is it possible to loop through all objects?

P: n/a
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.
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
br*@itnisk.com (Bryan) writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.