Multi-index assignment.

Jordan Harband ljharb at gmail.com
Mon Dec 4 19:28:22 UTC 2017


Can you elaborate on these situations?

In general, I find that using specific array indexes is most often a code
smell.

On Mon, Dec 4, 2017 at 11:21 AM, /#!/JoePea <joe at trusktr.io> wrote:

> I always run into situations where I'd like to assign some things from
> another array.
>
> For example,
>
> ```js
> array[0] = 1
> array[1] = 2
> ```
>
> could be written as
>
> ```js
> array[0, 1] = [1, 2]
> ```
>
> and maybe perhaps also specific access on the right hand side too:
>
> ```js
> array[1] = otherArray[3]
> array[4] = otherArray[5]
> // can be
> array[
> ​1​
> ,
> ​4​
> ] = [
>> otherArray[3]
>> ,
>> otherArray[
> ​5​
> ]
>> ]
> ​// but also a shorter form:
>
> array[1, 4] = otherArray[3, 5]
> ```
>
> */#!/*JoePea
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171204/e8db43aa/attachment-0001.html>


More information about the es-discuss mailing list