Eloquent Javascript Chapter 4 -
this question has reply here:
what advantage of initializing multiple javascript variables same var keyword? 5 answersfunction hasevent(event, entry) { homecoming entry.events.indexof(event) != -1; } function tablefor(event, journal) { var table = [0, 0, 0, 0]; (var = 0; < journal.length; i++) { var entry = journal[i], index = 0; // going on here? if (hasevent(event, entry)) index += 1; if (entry.squirrel) index += 2; table[index] += 1; } homecoming table; } console.log(tablefor("pizza", journal));
for above code - commented section doing? journal array of objects, each 2 properties, first of 'events' , contains array, sec boolean. can see object beingness accessed , stored in entry each loop through, don't know , index=0;
doing.
the comma allows multiple variables declared @ once, without having multiple var
statements.
var entry = journal[i], index = 0;
is equivalent to:
var entry = journal[i]; var index = 0;
javascript eloquent
No comments:
Post a Comment