Why javascript array element can't be accessed with dot notation? -
why it's not possible access array element dot notation?
var arr = ['apple', 'mango', 'pineapple', 'orange', {name: 'banana', color: 'yellow'}]; console.log( arr[0] ); // "apple" console.log( arr.0 ); // "apple" console.log( arr.3 ); // "orange" console.log( arr[4].name ); // "banana" console.log( arr.4.color ); // "color"
in other words, why language designers have chosen forbid identifiers starting number?
because identifiers not allowed start numbers, , y
in x.y
identifier.
why y
in x.y
identifier? no idea. ask language designers on appropriate mailing list or in ama session. i'd guess makes both language specification , interpretation wildly easier.
Comments
Post a Comment