How do i get all the class names that are present in a javascript file?
I am working on a code that displays all the public properties of a class present in a javascript file.Currently, the user types the name of the class in a text box. Instead of the user typing the name of the class in a text box, i want to display the list o开发者_如何学编程f classes present in the javascript file and allow the user to choose which ever class he wishes.
A solution in c# was to load the dll and the get all the types in the assembly using Assembly.getTypes() function. But am looking to find all the class types in a javascript file.
Is this possible? Will it be a problem as javascript is an interpreted language?
Any Help would be appreciated.
Thanks
Classes are nothing but functions in JavaScript, and functions are just variables. If you define a class like this:
function myClass() {
// ...
}
..it becomes a global variable (window.myClass), so you might take a look at the window object to find all defined (global) classes.
精彩评论