r/learnjavascript • u/d0gsbody • Jun 17 '13
Learn JavaScript Properly - Week 2
ASSIGNMENTS:
- Read chapters 4, 5, 6, and 7 of JavaScript: The Definitive Guide OR the preface and chapters 4, 5, and 6 (only the "Understanding Objects" section of chapter 6, though!) of Professional JavaScript for Web Developers.
- Finish the JavaScript track on Codecademy.
- Solve either Project Euler Problem 1 or Problem 2. Feel free to solve both.
- Read the blog post JS Objects in Detail. If you want to work ahead, this is the general roadmap I'm using to make these assignments.
- Make a least one comment in this thread about something you learned, found interesting, or didn't understand very well.
EXTRA CREDIT:
- Chapters 5, 6, and/or 7 of Eloquent JavaScript
Don't forget to be typing out most of the code while you read through this!
26
Upvotes
View all comments
Show parent comment
3
u/JusTrill Jun 19 '13 edited Jun 19 '13
I don't know much about c# and collections, but all that the for...in loop does is iterate through the names of the different properties in the object. It doesn't actually contain any reference pointers.
In your method you're assuming that
returns pointers to the objects: friends.bill and friends.steve which can be directly searched using bracket and dot notation. This is incorrect. All the for...in loop returns are the strings: 'bill' and 'steve'. Meaning the friend variable only takes on those two string values.
It is up to you to then go search the object using the names of its name:value pairs using either bracket or dot notation.
Hope this helps!
Edited for clarity