gpt4 book ai didi

javascript - 单行到多行 ES6 Fat Arrow 功能?

转载 作者:行者123 更新时间:2023-12-03 03:10:44 24 4
gpt4 key购买 nike

我正在学习 ES6 粗箭头函数。更改此代码的正确方法是什么,以便能够在指示的位置放置另一行,甚至 const a = 100; ,以便我可以向此函数添加更多行?

IMAdded: (options, args) => ({
IMAdded: {
filter: newIM => true, *need to add another line here*
},
}),

更新:

这是运行的 ES6 代码:

const subscriptionManager = new SubscriptionManager({
schema,
pubsub,
setupFunctions: {
APPTAdded: (options, args) => ({
APPTAdded: {
filter: appointment => (true),
},
}),
});

我想在返回 true 的代码中添加更多行。

最佳答案

如果您想将以下方法转换为具有更多行:

{
filter: appointment => true
}

您必须添加花括号和 return 语句:

{
filter: appointment => {
// ... add your other lines here
return true;
}
}

关于javascript - 单行到多行 ES6 Fat Arrow 功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41626753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com