Vik*_*ikR 21 javascript ecmascript-6
我正在学习ES6胖箭头功能.更改此代码的正确方法是什么,以便能够放置另一行,即使const a = 100;
在指定的位置,以便我可以为此函数添加更多行?
IMAdded: (options, args) => ({
IMAdded: {
filter: newIM => true, *need to add another line here*
},
}),
Run Code Online (Sandbox Code Playgroud)
更新:
这是运行的ES6代码:
const subscriptionManager = new SubscriptionManager({
schema,
pubsub,
setupFunctions: {
APPTAdded: (options, args) => ({
APPTAdded: {
filter: appointment => (true),
},
}),
});
Run Code Online (Sandbox Code Playgroud)
我想在返回的代码中添加更多行true
.
nem*_*035 35
如果要将以下方法转换为包含更多行:
{
filter: appointment => true
}
Run Code Online (Sandbox Code Playgroud)
你必须添加花括号和一个return
语句:
{
filter: appointment => {
// ... add your other lines here
return true;
}
}
Run Code Online (Sandbox Code Playgroud)