Status: New
Owner: ----
New issue 1837 by [email protected]: Defining properties in
Object.prototype returns invalid (boxed) values
http://code.google.com/p/v8/issues/detail?id=1837
V8 3.7.7
1. Open developer console in Chrome dev, write this:
Object.defineProperty(Object.prototype, "toArray", {value: function() {
return Array.isArray(this) ? this : [this];
}});
2. Then test this function
(1).toArray()
3. You'll see boxed [Number] output instead of desired [1]. So,
(1).toArray()[0] is new Number(1), instead of (new Number(1)).valueOf().
Same thing with String.
If you'll define a simple getter like this, everything would work, though:
Object.defineProperty(Object.prototype, "toArray", {get: function() {
return Array.isArray(this) ? this : [this];
}});
(1).toArray
[1]
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev