x1nick Posted November 28, 2011 Share Posted November 28, 2011 No idea what the correct naming is for this... In php you can do things like this $variable = 'my_class_name'; new $variable() or $variable = "class_{$class_name}" new $variable() I want to be able to do something similar in javascript, is this possible? This is my line of javascript which is clearly not going to work, but idx and file will change App.{idx}.{file} = new App.View.{file} Cheers Quote Link to comment Share on other sites More sharing options...
Adam Posted November 28, 2011 Share Posted November 28, 2011 With JS you can access object properties like an array, for reasons such as this. Give this a try: App[idx][file] = new App.View[file]; Quote Link to comment Share on other sites More sharing options...
x1nick Posted November 29, 2011 Author Share Posted November 29, 2011 Ah thanks, perfect! I knew that was possible as well but it just didnt cross my mind! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.