I'm having problem with private variables in JavaScript's Revealing Prototype Pattern. I can't figure out how can I have private variables that are used in several different functions inside shared (singleton) prototype, without exposing them. Here is the example of what I mean in JSFiddle.
The problem is in using var v
versus this.v
. First one messes the state of all instances, but second is publicly visible. Is there a way to have v private, and preserve its state for each individual instance?