How can I list the methods of a JavaScript object in VS command window?
-
04-07-2019 - |
Question
When debugging JavaScript in Visual Studio 2008 and I use the ? command in the command window to list a JavaScript object's members I always get that ellipses {...}. Example:
>? Page_Validators
{...}
[0]: {object}
[1]: {object}
[2]: {object}
[3]: {object}
[4]: {object}
[5]: {object}
length: 6
I'm assuming these are the object's member functions. Is there a way to list the members in that {...} ? A one-liner command would be ideal.
Thanks.
Solution
I just tried this and it works, with one caveat:
? (function () { var m = []; for (var p in Page_Validators) { if(typeof Page_Validators[p] == "function") { m.push(p); } } return m; })()
That will show you all of the methods that are part of the object, but none of the built-in inherited methods (like toString()
or valueOf()
).
Hope that helps.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow