I'm new to JavaScript and I'm having trouble understanding this sample code for a Q&A mobile app. The following code is for the question page of the mobile app:
for(var i = 0; i < question['answers'].length; i++){
var answer = question['answers'][i],
I've searched the mobile app's entire code and this is the only place ['answers']
is found.
question
is a controller and has already been defined, but ['answers']
--plural-- has never been defined prior to being used in this for
loop.
Anyone understand how this is possible?
question['answers']
is the same asquestion.answers
. – dystroy 9 mins agoquestion.answers
is valid... – BenM 9 mins ago