1 Reply Latest reply on Aug 28, 2008 4:57 AM by (Dave_Saunders)

    [JS] reference to object property by runtime

    Gerd2 Level 1
      Hi,
      is it possible to access an object property, where the property name is stored in a variable? e.g. i want to access:

      objectname.propname = 1;

      I need an access to 'propname' like this:

      pname = "propname";
      SetVal(objectname, pname, 1);

      I don't want the "hardcoded" variant like this:

      SetVal(oname, pname, val)
      {
      switch (pname) {
      case "propname":
      oname.propname = val;
      break;
      ...
      }
      }

      Thanks!
      Gerd