Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

[[Set]] or [[DefineOwnProperty]]? #2

Closed
Loirooriol opened this issue Aug 7, 2017 · 5 comments
Closed

[[Set]] or [[DefineOwnProperty]]? #2

Loirooriol opened this issue Aug 7, 2017 · 5 comments

Comments

@Loirooriol
Copy link
Contributor

Array.from creates properties with CreateDataPropertyOrThrow, which relies on [[DefineOwnProperty]].

Object.assign uses Set, which relies on [[Set]].

Which one is more appropriate for Object.fromEntries?

@bathos
Copy link
Collaborator

bathos commented Aug 7, 2017

I think you’re correct, CreateDataPropertyOrThrow is likely more appropriate because we already know the target object has no special [[Set]] behaviors to account for.

@bathos bathos closed this as completed in 975a8f5 Aug 7, 2017
Loirooriol added a commit to Loirooriol/object-from-entries that referenced this issue Mar 6, 2018
In tc39#2 it was decided to do this change to the algorithm, but the polyfill was not updated. This affects the result of `Object.fromEntries([["__proto__", {}]])`
@Loirooriol
Copy link
Contributor Author

https://github.com/bakkot/object-from-entries/blob/53993dcbfca226d3f91d5b83a41d9657be2fa7ee/DETAILS.md#L102-L104

@bakkot [[DefineOwnProperty]] is not consistent with Object.assign, which does trigger setters on Object.prototype.

@mathiasbynens
Copy link
Member

@Loirooriol Object spread ({ ...object }) does not trigger setters.

@Loirooriol
Copy link
Contributor Author

@mathiasbynens I know, and I prefer it if Object.fromEntries does not trigger setters either, but Object.assign does, and DETAILS.md says it doesn't.

@bakkot
Copy link
Collaborator

bakkot commented Mar 12, 2018

@Loirooriol Whoops, thanks, fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants