Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > is it possible to loop through all objects?

Reply
Thread Tools

is it possible to loop through all objects?

 
 
Bryan
Guest
Posts: n/a
 
      02-21-2004
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.
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      02-21-2004
(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 -
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Re: How to loop through a list while inside the loop, the list size may be decreased? Roedy Green Java 3 09-13-2008 01:51 AM
How to loop through all images of a page =?Utf-8?B?UG9udGlNYXg=?= ASP .Net 0 07-01-2004 09:30 AM
Object with all of form's controls to loop through ASP.NET David A. Beck ASP .Net 4 11-18-2003 03:04 AM
Loop through all dataadapters Vik ASP .Net 2 07-17-2003 02:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57