How to check if variable exists?

Howdy. I’ve got a base Weapon class with two inheritors: SmallGun and LargeGun. The SmallGun fires in bursts and has a new variable called burstCount. The LargeGun doesn’t.

In my scripts, how can I check if the variable burstCount exists in the current Weapon? Failing that, how would I check is the weapon is either a SmallGun or a LargeGun?

Thanks for the time.

Look into Reflection. I don’t know how much it is supported by JS, but it does whatever you are asking for. Keep in mind, however, that it’s slow. Also, I would still advice that you find a better solution. Having to check if a variable exists is rarely ever a good idea.