This kind of variables like "mode" should be constants IMHO, I mean, variables defined in the object. Something like this.MODE.INSERT or how you want to do this :)