Re: Adding .map() directly to String prototype

2018-05-17 Thread Rodrigo Carranza
In fact there should be a common interface that iterables should implement. I think this could have been proposed before. This way there would be not more common methods proposals. On may. 17 2018, at 10:16 am, Ben Fletcher wrote: Consider adding the array .map()

RE: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
> I was about to hit send on a post also suggesting a helper function, but > after thinking about it a bit more, Rodrigo's suggestion resembles extending > the optional chaining proposal >

RE: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
ategoryId?, postType? }) } ``` De: kai zhu <kaizhu...@gmail.com> Enviado: martes, 28 de noviembre de 2017 11:43 p.m. Para: Rodrigo Carranza Cc: J Decker; Michał Wadas; es-discuss@mozilla.org Asunto: Re: A way to prevent properties to be added to an object if they are null or undefined.

RE: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
and it is acting weird. Also I'm new to mailing lists. De: J Decker <d3c...@gmail.com> Enviado: martes, 28 de noviembre de 2017 09:07 p.m. Para: Michał Wadas Cc: Rodrigo Carranza; es-discuss@mozilla.org Asunto: Re: A way to prevent properties to be added to an

Re: Re%3A A way to prevent properties to be added to an object if they are null or undefined.=<CABOscaYZcYD%2BFqp6pyNB6%3D908xfObLznsovXavQg58sL%2B%3Dx%2BXg%40mail.gmail.com>

2017-11-28 Thread Rodrigo Carranza
Yeah, it was wrong, I'm currently using like ```js let ret = { ... ( couldBeNull ? {couldBeNull} : {} ) } ``` Yours is better and the usual idiom a bit hard to understand. What I'm proposing is something like this ```js let ret = { couldBeNull? } ``` or if you want a different name for the

Re: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
Yes, like that, but that will require to modify the object. Compare this ```js let a = {} a.field ?= couldBeNull ``` To: ```js let a = { field ?: couldBeNull } ``` Also if you want to set the property with the same name of the variable ```js let field = ... let a = { field? } ``` Why

Re: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
Yes, like that, but that will require to modify the object. Compare this ```js let a = {} a.field ?= couldBeNull ``` To: ```js let a = { field ?: couldBeNull } ``` Also if you want to set the property with the same name of the variable ```js let field = ... let a = { field? } ``` Why

Re: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
It's about the value of the property to be added, nothing to do with the name of the property. It should discard properties whose value are null(but this behavior is not always desired, so a different syntax for these properties should be added). ``` On nov. 28 2017, at 8:33 pm, Sebastian

A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
A way to prevent properties to be added to an object if they are null or undefined. Currently this can be accomplished in many ways: With an if: ```js function foo(couldBeNull){ let ret = {} if(couldBeNull){ ret.couldBeNull = couldBeNull } return ret } ``` With ternary (kind of gross) ```js