You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
Has there been any discussion about removing/filtering keys during spread?
For example:
let x = { a: 1, b: 2, c: 3, };
let y = { ...x, c: undefined, };
// y is { a: 1, b: 2, c: undefined, }
let z = { ...x, delete c, }; // possible syntax
// z is { a: 1, b: 2, }
At the moment, z is currently achievable using this multi-statement code:
let z = { ...x, };
delete z.c;
or using this single-expression but rather verbose and potentially-less-optimizable code:
let z = Object.entries(x).reduce((o, [k, v]) => (k !== 'c' && (o[k] = v), o), {})
It'd be nice if it could be done in an object spread expression, perhaps using my proposed syntax.
The text was updated successfully, but these errors were encountered:
Has there been any discussion about removing/filtering keys during spread?
For example:
At the moment,
z
is currently achievable using this multi-statement code:or using this single-expression but rather verbose and potentially-less-optimizable code:
It'd be nice if it could be done in an object spread expression, perhaps using my proposed syntax.
The text was updated successfully, but these errors were encountered: