Spread operator copies Symbol property from one to another object
Reported by
konr...@gmail.com,
Jan 27 2018
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Steps to reproduce the problem:
1. Define object on which Symbol will be used as property name (e.g. obj[Symbol("secret property")] = "secret value")
2. Using spread operator copy all properties to another object (e.g. const newObj = {...obj})
What is the expected behavior?
Spread operator should copy only own `enumerable` (which is not relevant to the property named using Symbol as it's not enumerable) properties from a provided object onto a new object.
What went wrong?
All properties including property with name using Symbol are copied into new object.
Did this work before? N/A
Chrome version: 63.0.3239.132 Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
working example: https://goo.gl/SkHd3H
,
Jan 28 2018
,
Jan 28 2018
What I see here is inconsistency. On the one hand `spread operator` and `Object.assign` both do copy `Symbol` property. On the other hand, `Symbol` property doesn't appear in `for...in` loop and completely ignored by `JSON.stringify/JSON.parse`.
,
Jan 31 2018
,
Feb 6 2018
,
Feb 6 2018
Pretty sure this is working as intended per spec, but assigning to gsathya in case I've got that wrong. Note that this spec is now stage 4, and will be part of ES2018. If you'd like to further discuss this issue, I recommend opening an issue at https://github.com/tc39/ecma262. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by woxxom@gmail.com
, Jan 27 2018