You need to understand that
person.usr
is exactly the same as
person["usr"]
. Arrays and other objects are pretty much the same thing:
associative container. Perhaps the only difference for array is its predefined property
length
.
It's weird that you want to store titles in the array. You should better store the objects themselves:
var array = [
{title: "Mr", pass: "I won't tell you"},
{title: "Mrs", pass: "Get lost!"},
{species: "Turdus migratorius", genus: "Turdus",
family: "Turdidae",
conservationStatus: "least concern"}
];
var someProperty = array[2].family;
Any questions?
Javascript is said to be the most misunderstood language of all times. Please see:
http://davidwalsh.name/javascript-objects-distractions[
^].
—SA