In the following statement:
let x=[1,2,3];
console.log(x.0); // should be console.log(x[0])
This evaluates to an error:
SyntaxError: missing ) after argument list
I have two questions about this:
- For array syntax, is the only way to reference an element using
arr[idx]
syntax and notarr.idx
? - Why does it give the above error and not something like, "property 0 not valid identifier"?