我從一個庫中獲得以下代碼,並且我想知道將參數/變量與{}關聯起來,還有一個沒有它們之間有什麼區別?{參數}和參數之間的區別?
行我指的是這個:
send({sessionId}, {text})
下面是完整的代碼:
const actions = {
send({sessionId}, {text}) {
// Our bot has something to say!
// Let's retrieve the Facebook user whose session belongs to
const recipientId = sessions[sessionId].fbid;
if (recipientId) {
// Yay, we found our recipient!
// Let's forward our bot response to her.
// We return a promise to let our bot know when we're done sending
return fbMessage(recipientId, text)
.then(() => null)
.catch((err) => {
console.error(
'Oops! An error occurred while forwarding the response to',
recipientId,
':',
err.stack || err
);
});
} else {
console.error('Oops! Couldn\'t find user for session:', sessionId);
// Giving the wheel back to our bot
return Promise.resolve()
}
},
// You should implement your custom actions here
// See https://wit.ai/docs/quickstart
};
謝謝,Madara Uchiha!非常感激。 – fobia