var statusCodes = {};
statusCodes[exports.ACCEPTED = 202] = "Accepted";
what does the second line mean? More specifically, the part in the squared brackets.
var statusCodes = {};
statusCodes[exports.ACCEPTED = 202] = "Accepted";
what does the second line mean? More specifically, the part in the squared brackets.
Complex things are made of multiple simple things. Just look at it one operation at a time.
First this operation is performed:
exports.ACCEPTED = 202
Which sets exports.ACCEPTED
to the value 202
, and the operation evaluates to the value 202
. Then this operation is performed:
statusCodes[202] = "Accepted"
Which sets statusCodes[202]
to the value "Accepted"
.
It's just a shorter version for
var statusCodes = {};
exports.ACCEPTED = 202;
statusCodes[exports.ACCEPTED] = "Accepted";
Check this question to get the idea