Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35953
| From | Martin Honnen <martin.honnen@gmx.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: let and {} |
| Date | 2019-01-03 17:32 +0100 |
| Organization | Liberty Development |
| Message-ID | <q0ldf1$g3t$1@news.albasani.net> (permalink) |
| References | <q0lao9$1vie$1@gioia.aioe.org> |
On 03.01.2019 16:46, Luca wrote:
ease bear with me if I ask this honorable forum:
>
> Inside a class:
>
> this.state = {
> gameState: "ready",
> wrongGuesses: [],
> correctGuesses: []
> };
>
> :
>
> let { wrongGuesses, correctGuesses } = this.state;
>
> Questions:
>
> 0) what's the meaning of curly braces there?
>
> 1) why does this work? i.e. why are wrongGuesses and correctGuesses
> being assigned correctly?
>
> 2) what's the scope of wrongGuesses and correctGuesses?
>
> 3) why isn't this.gameState "interfering" with what needs to be asigned
> to what?
>
> 4) is this an ES5 or ES6 feature?
See whether
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring
and
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let
helps.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
let and {} Luca <luca@please.nospam.it> - 2019-01-03 10:46 -0500
Re: let and {} Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-01-03 16:31 +0000
Re: let and {} Luca <please_no@spam.it> - 2019-01-03 13:13 -0500
Re: let and {} Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-01-03 20:07 +0000
Re: let and {} Luca <luca@please.nospam.it> - 2019-01-03 23:45 -0500
Re: let and {} Martin Honnen <martin.honnen@gmx.de> - 2019-01-03 17:32 +0100
Re: let and {} Luca <please_no@spam.it> - 2019-01-03 13:14 -0500
csiph-web