Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Implementing Python's dir() for classic JScript

34 views
Skip to first unread message

F. S. Farimani

unread,
Dec 8, 2020, 2:33:17 PM12/8/20
to
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.
0 new messages