arrays - JavaScript syntax issue: [{ }] hierarchy -
i came across following nested array , little confused why uses particular syntax:
var allquestions = [{ question: "which company first implemented javascript language?", choices: ["microsoft corp.", " sun microsystems corp.", "netscape communications corp."], correctanswer: 2 }];
full example: http://jsfiddle.net/alxers/v9t4t/
is common practice use [{...}]
having declared such variable?
the definition array object literal in it. not realy nested array.
{ question: "which company first implemented javascript language?", choices: ["microsoft corp.", " sun microsystems corp.", "netscape communications corp."], correctanswer: 2 }
is object literal, array contains. in fiddle linked there several of these defined in allquestions
array. doing makes easy loop on array of questions , display each in turn.
Comments
Post a Comment