Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38468

Re: let syntax

From James Kirk <noneya.invalid@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: let syntax
Date 2020-06-15 00:06 -0400
Organization Time Travel Tracing
Message-ID <20200615000641.7bb3c5c9@james.kirk.invalid> (permalink)
References <Gt-dnYgvE8ieWHvDnZ2dnUU7-QnNnZ2d@westnet.com.au> <20200614212651.513dc927@james.kirk.invalid> <sa2dndANOaaDd3vDnZ2dnUU7-IfNnZ2d@westnet.com.au>

Show all headers | View raw


In Message: <sa2dndANOaaDd3vDnZ2dnUU7-IfNnZ2d@westnet.com.au>
Andrew Poulos <ap_prog@hotmail.com> wrote:

> On 15/06/2020 11:26 am, James Kirk wrote:

>> In Message: <Gt-dnYgvE8ieWHvDnZ2dnUU7-QnNnZ2d@westnet.com.au>
>> Andrew Poulos <ap_prog@hotmail.com> wrote:

[snip]

>>> let { target:el } = e;  

[snip]

>>> I don't understand how the first line in "move" works. It seems
>>> that 

>>> let { target:el } = e;
>>> is equivalent to
>>> let el = e.target;  

>>> but how?  

>> Destructuring assignment

>> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

> Cool, a whole new area I knew nothing about!

> In this case, why would choose one rather than the other?


personal preference, readability, modifications … no reason not to
use destructuring assignment

for example if the event type would be needed at a later time.

let { target:el, type:evtype } = e;


-- 
James Kirk

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

let syntax Andrew Poulos <ap_prog@hotmail.com> - 2020-06-15 10:46 +1000
  Re: let syntax James Kirk <noneya.invalid@gmail.com> - 2020-06-14 21:26 -0400
    Re: let syntax Andrew Poulos <ap_prog@hotmail.com> - 2020-06-15 13:25 +1000
      Re: let syntax James Kirk <noneya.invalid@gmail.com> - 2020-06-15 00:06 -0400
      Re: let syntax Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-06-16 21:23 +0200
        Re: let syntax Andrew Poulos <ap_prog@hotmail.com> - 2020-06-17 10:24 +1000
        Re: let syntax Julio Di Egidio <julio@diegidio.name> - 2020-06-16 21:19 -0700

csiph-web