Proposal: minus operator for the spread operator

Felipe Nascimento de Moura felipenmoura at
Tue May 12 13:43:33 UTC 2020

hm, personally, I find it useful when extracting properties from objects!

I have myself been in situations where I had to deal with "all other
properties except...".
An alternative would be simply extract it normally, but ignore it (which
triggers complaints from linters).

Perhaps `!` could be a better option (makes me think of .gitignore and
other list remove syntaxes.

const { propA, propB, !keyToRemove, ...other } = objectA;

Note that, if you are not getting the "rest" of the properties in an
`...other` constant, it would not be as useful.
In this case, keyToRemove would NOT be declared, and other would have all
properties except propA, propB and keyToRemove.

Other thing I find rather annoying is the way we have to deal with some
APIs when we are trying to "clean" their returned objects.
Like so:

function cleanData (data) {
const { propA, propB, propC, propD, propE } = data;
return { propA, propB, propC, propD, propE };

Perhaps something like this could become an option?!

function cleanData (data) {
const { propA, propB, propC, propD, propE } as newObj = data;
return newObj;

[ ]s


*Felipe N. Moura*
Web Developer, Google Developer Expert
<>, Founder of
BrazilJS <>, Nasc <> and On2

Website: /
Twitter:    @felipenmoura <>
* Changing  the  world*  is the least I expect from  myself!

On Sun, May 3, 2020 at 6:57 AM devlato <ecma6 at> wrote:

> Hey folks,
> I've figured out a potential improvement for the object spread syntax and
> want to share my thoughts.
> I've drafted my thoughts into a proposal available here:
> <>
> Long story short, I want to propose a new **minus operator**, that would
> allow specify keys to remove the values from a result of object spread. It
> would look like this:
> const result = {
>   ...objA,
>   ...objB,
>   -keyToRemove,};
> // Or like this – the same result!const result = {
>   ...objA,
>   -keyToRemove,
>   ...objB,};
> // And this!const result = {
>   -keyToRemove,
>   ...objA,
>   ...objB,};
> What do you folks think?
> Warmest regards,
> Denis
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list