From what I've learned, you can't access the instance vars by name, because the minifier converts all full variable names to minified names. You can access them using an index number, as you mentioned in the OP, but that can be an unreliable solution. If instance vars get added or removed, then your index changes.
If your solution works, then that is probably the best way.