-1
var statusCodes = {};

statusCodes[exports.ACCEPTED = 202] = "Accepted";

what does the second line mean? More specifically, the part in the squared brackets.

KMA Badshah
  • 895
  • 8
  • 16
  • 1
    It's just an assignment. Assignments return the value assigned, so it's equivalent to `exports.ACCEPTED = 202` and `statusCodes[202]`. – jonrsharpe Jul 02 '20 at 16:05

2 Answers2

1

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".

David
  • 208,112
  • 36
  • 198
  • 279
0

It's just a shorter version for

var statusCodes = {};
exports.ACCEPTED = 202;
statusCodes[exports.ACCEPTED] = "Accepted";

Check this question to get the idea

Value returned by the assignment

Ximik
  • 2,435
  • 3
  • 27
  • 53