blob: c979d3b400329796157a0d7ea64ac7075abf64cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
function f() {
for (var i=0; i<100; i++) {
var obj = {data: {id:1}};
}
Object.defineProperty(obj, "id", {
configurable: true,
enumerable: false,
get: function() {
return this.data.id;
}
});
return obj.id;
}
assertEq(f(), 1);
function f2() {
for (var i=0; i<100; i++) {
var obj = {data: {id:1}};
}
Object.defineProperty(obj, "id", {
configurable: true,
enumerable: false,
get: function() { return this.data.id; },
set: function(v) { this.data.id = v; }
});
obj.id = 3;
return obj.id;
}
assertEq(f2(), 3);
|