【问题标题】:Objects in anonymous functions [duplicate]匿名函数中的对象[重复]
【发布时间】:2020-04-06 05:21:23
【问题描述】:

看看下面的两行。

foo = ({ data: { one, two }}) => {alert(one.type); alert(two.type);}
foo( /* What goes here*/ );

我会在第二行的 () 中添加什么来提醒第一个 alert() 中的“Hello”和第二个 alert() 中的“World”?

【问题讨论】:

  • foo({data: {一: {type: "Hello"}, 二: {type: "World"}}})

标签: javascript


【解决方案1】:

您需要使用具有数据键的对象调用 foo 函数。数据也是一个具有两个键 onetwo

的对象
foo({
    data: {
       one: {type: 'one'},
       two: {type: 'two'}
    }

})

你需要了解的是 foo 组件正在使用对象破坏

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-11
    • 2013-05-13
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    • 2022-11-05
    相关资源
    最近更新 更多