I am writing a program whereby a user can define JS variables, as they are basically writing JS into the program (much like a tutorial) and I would like to keep an array of the variable names. For example, I have an object called Particle, which is defined as the following:
function Particle(x, y, force, angle) {
this.force = new Force(force, angle);
this.pos = new Position(x,y);
}
And if the user creates one with the following syntax:
var bus = new Particle(0,0,4,45)
I would like to be able to append 'bus' to an array, however I do not know how to get the name of the variable from within the variable. There is probably something major I am overlooking, however does anyone know how to retrieve this?