I found a code in a article as below. In this code, what does jsonrequest[define.AddStudent]) mean? Does the [define.AddStudent] resembles 'contains of' string in the variable jsonrequest? Kindly help what does line B mean?
var jsonrequest = JSON.parse(data); //Line A
if(jsonrequest[define.AddStudent]) { // Line B
//where define.AddStudent="add student";
console.log("Request for " + define.AddStudent);
}
The jsonrequest variable is a JavaScript object.
The define variable is also a JavaScript object. AddStudent is a property / method of the define object. Let us assume that it is a string property containing "add student", as the comment tells us.
Then, the meaning of line B is: "If the property named "add student" of the jsonrequest object is defined."