1. Digitizing people


#1

Hey codecademy users,

var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-777",
email: "bob.jones@example.com"
};

console.log(bob.firstName);
console.log();
console.log();

Regarding the default code in the editor, the instructions explain that Bob's information is stored in an associative array. To me, it just looks like an object opposed to an associative array (whatever that is) or are they they same thing? Can somebody clarify this for me.


#2

@tyoungg,

++++ the object as an associative array
++++++++++++++++++++++++++++++++
They were taking a line out of the
developer.mozilla.org manual, look here subject::
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects

[[ Begin of quote ]]
Properties of JavaScript objects can
also be accessed or set
using a bracket-notation. ( this in contrast to the = literal-notation = )

Objects are sometimes called associative arrays,
since each property is associated with a string value ( call it the property-key )
that can be used to access it.

Having a myCar object like:

 var myCar = {
          make: "Ford",
         model: "Mustang",
           year: 1969
        };

for example, you could access the properties of the myCar object as follows:
myCar["make"] = "Ford";
myCar["model"] = "Mustang";
myCar["year"] = 1969;
[[ End of quote ]]

The 3 possibilties to get access to the property VALUE

1 Via the so-called DOT-notation, here you use the

literal-property-key-name (NO variable-name allowed)
like:
myCar.year ==wil give you the associated number-VALUE => 1969

2 Via the so-called bracket-notation...

2a ---

We use the literal-property-key-name-as -a-string in brackets
myCar["year"] ==wil give you the associated number-VALUE => 1969

2b ---

We declare a variable which has the property-key-name-as -a-string
assigned to it... like:
**var theKey = "year";
myCar[theKey] ==wil give you the associated number-VALUE => 1969
( They also call this, getting at the -associated- VALUE by reference )


#3

Thanks @leonhard_wettengmx_n :smiley: I need 20 characters to send this thank you message.


#4

Very informative, thank you.