Working with es6 const, let
a-x- opened this issue · 4 comments
a-x- commented
is there definition for the case:
const {fooBar} = res?.data?.buisnessData // equals const fooBar = _.get(res, 'data.buisnessData.fooBar')
claudepache commented
@a-x- const/let and destructuring is orthogonal to optional chaining. In particular, Nothing new.const {fooBar} = anything
is always equivalent to: const fooBar = anything.fooBar
.
I don’t know what you mean by _.get(...)
.
a-x- commented
_
is the lodash
:
https://lodash.com/docs#get
a-x- commented
thank you
claudepache commented
In reality, as currently specced, const {fooBar} = <anything>
is not equivalent to:
const fooBar = <anything>.fooBar
but to:
const tmp = <anything>
const fooBar = tmp.fooBar
which makes a difference when <anything>
is an expression containing an optional chaining operator; see #7.