Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not extend Array.prototype #2112

Closed
neumino opened this issue Mar 18, 2014 · 2 comments
Closed

Do not extend Array.prototype #2112

neumino opened this issue Mar 18, 2014 · 2 comments
Assignees
Milestone

Comments

@neumino
Copy link
Member

neumino commented Mar 18, 2014

Instead of saving things in this.__proto__ when we send back an array, I'm changing the internal prototype after the objects are created.
That way, we keep all the usual checks valid for Arrays.

Review 1326 assigned to @AtnNn
Branch michel_arrayresult

michel@T520:~$ node
> a = [1,2,3]
[ 1, 2, 3 ]
> a.__proto__ = {}
{}
> a.__proto__["toArray"] = function() { return this.slice(0, this.length) }
[Function]
> a.__proto__.__proto__ = [].__proto__
[]
> a
[ 1, 2, 3 ]
> a.toArray()
[ 1, 2, 3 ]
> a instanceof Array
true
> Object.prototype.toString.call(a)
'[object Array]'
> a.constructor
[Function: Array]
@neumino neumino added this to the 1.12 milestone Mar 18, 2014
@neumino neumino self-assigned this Mar 18, 2014
@coffeemug coffeemug modified the milestones: 1.12-polish, 1.12 Mar 19, 2014
@coffeemug
Copy link
Contributor

Moving to polish. I think we should have a stricter rule to only keep issues in 1.12 if we're willing to hold the release for them.

@neumino
Copy link
Member Author

neumino commented Mar 20, 2014

Merged in next as f9c0e52
Ship 1.12

@neumino neumino closed this as completed Mar 20, 2014
@AtnNn AtnNn modified the milestones: 1.12, 1.12-polish Mar 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants