I am trying to replicate a "function" of PHP (and in most languages) in Javascript.
Here it is in PHP:
$objectName = 'ObjectA';
$someObject->$objectName->someMethod();
Mostly a string variable is used to refer to an object variable.
So, in Javascript, I was hoping to do something like:
var objectName = "ObjectA";
someObject.[objectName].someMethod();
Does anyone know how to do this? Or if it is even possible?
source
share