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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -