Variables store a value, not a memory location history. If you want to do something like this, I would suggest you use an object of some kind:
var x = { value: false, history: [], set: function(val){ history.push(this.value); this.value = val; }, wasEver: function(val){ return this.history.indexOf(val) >= 0; } };
Then you can use the object as follows:
x.set(false); x.value; //returns false x.set(true); x.value; //returns true x.wasEver(true); // returns true x.wasEver(false); //returns true x.wasEver("hello"); //returns false
This gives each object in which it has a history (for example, it can check several values, and not just one - as is the case with the recipient / installer material mentioned in other answers), and is guaranteed to work in any field, since all the functionality contained in a particular object.
source share