私はちょうど新しい仕事を始めました。維持するいくつかのリアクションコードがあります。authenticationHandlers.js
というファイルがあります。私が遭遇したこのjavascriptの構文に慣れていない
const events = require("./authenticationEvents.js");
const authenticationHandlers = {
[events.Errored.Name](prev, event) {
const update = {
UnauthorizedError: event.Error
};
return Object.assign({}, prev, update);
},
[events.ClearError.Name](prev, event) {
const update = {
UnauthorizedError: null
};
return Object.assign({}, prev, update);
}
};
module.exports = authenticationHandlers;
ブラケットが何を意味するのですか?私は本当にコードの機能についてのご質問はありませんが、ブラケットの構文は、言い換えればライン[events.Erorred.Name]
と[events.ClearError.Name]
で何をするのか
イベントオブジェクトからの名前を持つ2つの関数を定義しようとしているようです – klikas