New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 739991 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Closed: Jul 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

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:
 

Comment 1 Deleted

Cc: krajshree@chromium.org
Labels: Needs-Feedback
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...!!

Comment 3 by woxxom@gmail.com, 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}

Comment 4 by woxxom@gmail.com, 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.

Comment 5 by alph@chromium.org, Jul 10 2017

Owner: l...@chromium.org
Status: WontFix (was: Unconfirmed)
This is exactly how DevTools determines the object is an array, by presence of length and splice properties.

Sign in to add a comment