3 ms·
I'm not sure why you think local variable names are mattering here... What's happening is that this expresion: const { error, value } = obj; where obj is
by bzbarsky 12y ago
I'm not sure why you think local variable names are mattering here...
What's happening is that this expresion:
const { error, value } = obj;
where obj is an object will assign obj.error to error and obj.value to value.
You could name your locals something else if you wanted, of course:
const { error: myError, value: myValue } = obj;
will assign obj.error to myError and obj.value to myValue. There just happens to be a shorter syntax for the common
const { error: error, value: value } = obj;
case.
- jrochkind1 12y agoAh, it's a slice, I get it now, thanks.