1. Associative array? You mean OBJECT?!


#1

What is associative array? bob is not an an associative array, bob is an object, written using literal notation.

See info here: http://www.w3schools.com/js/js_arrays.asp

Someone really needs to go over the terminology being used in these courses because it's sometimes inconsistent, and it makes learning the new terminology more difficult. There's several occurrences like this in the Javascript lessons that I've found, and I'm sure I've missed some.


#2

@jclahoot,

++++ 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

I understand this, but a lesson can't just swap in an equivalent term without providing any context. It's really good to know what those terms are and there's a lot of value there, but new terms have to be explained otherwise they become confusing. Imagine if in an English class the teacher was giving a lesson about verbs, but suddenly started calling it something completely different (but correct) without explaining themselves. The students would just lose their train of thoughts because they'd be stuck on the fact that "that's not a X, that's a verb!" The text just needs to be changed to explain it, and this isn't the first time that someone has brought it up either.


#4

Totally agree. The lesson even states:

"To access the values for each property we write array.property "

...Throughout this course, we haven't seen properties used in the context of arrays; furthermore, this seems out of place and is confusing since we are supposed to be learning about objects in this module.

I've liked your post and commented here so that it'll help bring awareness to your post. Hopefully a Codeacedemy moderator will take notice.


#5

Looking back, knowing that Objects (in JavaScript) act similarly to associate arrays (in other programming languages) would have been really helpful for the Contact List problem in Unit 6: Data Structures.

I was very confused why we had to access the "properties" of the friends objects (Bill and Steve) using bracket notation, yet we had to use dot notation to access the properties within those inner-objects. e.g. friends[key].firstName

The context of the lesson made me think in terms of using "objects within objects" - that objects can have properties in which the values are objects themselves.

Again, I'm only writing this to provide feedback on how I felt about the course. I understand the concepts now, but it seems like it could have been structured better to avoid unnecessary headache.


#6

I see you are allready are doing the Javascript-track.
Also try to familiarise yourself with the story:

Once upon a time there was THE OBJECT,
he was surrounded by the applicAtions,
he was lonely so THE OBJECT gave the applicAtions the abillity to create new objects
but the rule was

var a-name = new Object();

so THE OBJECT became the boss over all those new objects.
He was literally flooded with new objects.
And what was even worse
there where an almost uncountable INSTANCES of those new Objects around.

So in an effort to organise the mess he created,
he decided to
promote specific objects to be a boss and gave them the title CLASS-object.

Result was that THE OBJECT was now only confronted with 2 things…

  • 1 creating new objects,
    • but he directly promoted them to be either a Class-object,
    • or the new object became a member of a Class-object
      • to make the new object a member of a specific Class-object
      • THE OBJECT
      • has to call out to the name of the Class-object and =shout=
        • prototype this object.
  • 2 handling all requests from his Class-objects which they can't resolve.

You sitting at your computer screen...
Or is it you as an Instance of the Person-object,
with the a property with key-attribute being your position with a value sitting.
It is getting weirder and weirder...

What should also be told is the fact that
THE OBJECT has declared that
only the Class-objects may have names starting with a Capital-letter.

And THE OBJECT invented the so called camel-style of writing,
like carFactoryEntranceSecurityMeasures.
So long.. keep on tracking ..

===============================================

Reference

google search
== the Book ==
javascript [your question] site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html
http://javascript.crockford.com/survey.html
http://stackoverflow.com/questions/9549780/what-does-this-symbol-mean-in-javascript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
www.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname?rq=1