window.a = 42;
var b = { ref: "window.a"; };
var readRef = function(ref) {
return eval(ref);
}
console.log(readRef(b.ref));
delete window.a;
console.log(readRef(b.ref));
The downside is you need the full rooted path to the variable. But maybe JS has some reflection to help generate the full rooted path.