new operator with length and splice
Reported by
nickel.z...@gmail.com,
Jul 7 2017
|
|||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
Steps to reproduce the problem:
1. var foo = function() {this.length = 0;}
2. foo.prototype.splice = function() {};
3. var f = new foo();
4. console.log(f);
What is the expected behavior?
prints a string as "{length:0}";
What went wrong?
prints a string as "[]";
Did this work before? N/A
Chrome version: 58.0.3029.110 Channel: stable
OS Version: OS X 10.12.4
Flash Version:
,
Jul 7 2017
nickel.zheng@ - Thanks for filing the issue...!! Could you please provide a sample test file to test the issue from TE-end. This will help us in triaging the issue further. Thanks...!!
,
Jul 7 2017
#2, just run the code in the report (without the initial numbers) in a devtools console of the new tab page:
var foo = function() {this.length = 0;}
foo.prototype.splice = function() {};
var f = new foo();
console.log(f);
==========================
Firefox and Chrome: []
Internet Explorer: {length: 0}
Edge: {length: 0}
,
Jul 7 2017
It should be noted that this is a purely devtools console display issue.
It seems to guess the object type by the presence of "length" property.
The underlying V8 implementation correctly sees "f" as an object:
JSON.stringify(f) produces "{length: 0}" as expected.
,
Jul 10 2017
This is exactly how DevTools determines the object is an array, by presence of length and splice properties. |
|||
►
Sign in to add a comment |
|||
Comment 1 Deleted