Possible Duplicate:
Create instance of “Class” Using “Reflection” in JavaScript
Java has Class.forName("XYZClass") to load class at run time. Is there any alternate for Class.forName("XYZClass") in JavaScript?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Personally I think you are trying to literally translate Java code to JavaScript rather than using idiomatic constructs (well,
Class.forName()isn’t idiomatic in Java as well). However, let’s give it a try:This is your class. Normally you would create it using:
With “reflection” in JavaScript this works: