by Sephr · 8y ago · 0 comments
let i = 0, a = {valueOf: () => ++i};
if (a == 1 && a == 2 && a == 3) {
console.log("all equal");
}
Object.defineProperty (modern version of __define[GS]etter__): let i = 0;
Object.defineProperty(self, "a", {get: () => ++i});
if (a == 1 && a == 2 && a == 3) {
console.log("all equal");
} var i = 0;
window.__defineSetter__("x", function(value) { i = value; });
window.__defineGetter__("x", function() {
// LCG, a = 4, c = 1, m = 9;
i = (4 * i + 1) % 9;
return i;
});
x = 3;
if(x === 4 && x === 8 && x === 6) {
"wtf!";
}