Heterogeneous arrays


arrays and objects in JS heterogeneous arrays

says"syntaxError : missing ] after element list"

Replace this line with your code. 
var myArray = [7, true, "hello" Object];


After "hello" word you need to put a comma to separate array items.


Apart from the missing comma, Object is not what you might think. When we declare an object, we write,

new Object()   // constructor


{}             // object literal

as in,

... "hello", { name: "object literal" }


thanks so much, helped a ton!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.