销毁嵌套对象:如何获得父级及其子级值?

销毁嵌套对象:如何获得父级及其子级值?,第1张

销毁嵌套对象:如何获得父级及其子级值?

第一个解构仅创建

Start
End
变量。如果要创建
current
为变量,则需要再次声明。

function ({ current: { selectionStart: Start, selectionEnd: End }, current }, AppStateSetter) {// do something with current , Start , and End}

您可以在Babel编译器上对其进行测试:

这段代码:

const object = {  current: {    selectionStart: "prop 1",    selectionEnd: "prop2"  }}const { current: { selectionStart: Start, selectionEnd: End } } = object;

被转移到:

var object = {  current: {    selectionStart: "prop 1",    selectionEnd: "prop2"  }};var _object$current = object.current,    Start = _object$current.selectionStart,    End = _object$current.selectionEnd;

如您所见,

current
未创建变量。



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5614945.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存