Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > microsoft.public.scripting.jscript > #2
| Newsgroups | microsoft.public.scripting.jscript |
|---|---|
| Date | 2020-12-08 11:33 -0800 |
| Message-ID | <ae773307-cd7f-4fc5-89b1-d2c61aeaa031n@googlegroups.com> (permalink) |
| Subject | Implementing Python's dir() for classic JScript |
| From | "F. S. Farimani" <f.s.farimani@gmail.com> |
With little documentation available for JScript a dir() function, like the one in Python, could be really handy. I was thinking if I could implement such a function to list all the properties and methods an object carries.
I looked at the options on this page
https://stackoverflow.com/questions/5523747/equivalent-of-pythons-dir-in-javascript
Sadly the Object.keys() and Object.getOwnPropertyNames() methods don't exist in JScript. And the other option using in operator:
function dir(inputObject) {
properties = [];
for (property in inputObject) {
properties.push(property);
}
properties.sort();
return properties;
}
returns an empty Array. I would appreciate it if you could help me know if/how this could be implemented in JScript.
P.S. I had previously asked this question here on SO
https://stackoverflow.com/q/64849017/4999991
but sadly it has been removed with no further explanation.
Back to microsoft.public.scripting.jscript | Previous | Next | Find similar
Implementing Python's dir() for classic JScript "F. S. Farimani" <f.s.farimani@gmail.com> - 2020-12-08 11:33 -0800
csiph-web