Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35952
| From | Jon Ribbens <jon+usenet@unequivocal.eu> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: let and {} |
| Date | 2019-01-03 16:31 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrnq2se7a.1f4.jon+usenet@sable.unequivocal.eu> (permalink) |
| References | <q0lao9$1vie$1@gioia.aioe.org> |
On 2019-01-03, Luca <luca@please.nospam.it> wrote:
> let { wrongGuesses, correctGuesses } = this.state;
>
> Questions:
>
> 0) what's the meaning of curly braces there?
It's called "destructuring", the above is basically the same as:
let wrongGuesses = this.state.wrongGuesses
let correctGuesses = this.state.correctGuesses
Without the curly braces, it would be the same as:
let wrongGuesses
let correctGuesses = this.state
> 1) why does this work? i.e. why are wrongGuesses and correctGuesses
> being assigned correctly?
Not sure I understand that question.
> 2) what's the scope of wrongGuesses and correctGuesses?
The scope of 'let' variables is the block in which they are declared.
This is different from 'var' variables, the scope of which is the
entire function in which they are declared (or global if they are
declared outside a function).
> 3) why isn't this.gameState "interfering" with what needs to be asigned
> to what?
I don't understand this question either.
> 4) is this an ES5 or ES6 feature?
ES6.
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