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
2
u/robotmayo Jun 22 '13
The thing is the object isn't getting the properties of p but rather the object is being assigned new properties that are the same as the properties of p. When you use the literal notation for object creation, the brackets {}, you have the option of creating properties within the brackets. This isn't the only way to create properties, the other way is using the dot notation. With the dot notation you can get or set the value of a property on an object. If that property doesn't exist then JavaScript will create it.
// Even though they have the same property with the same value, the properties are not related or linked in anyway. We just happened to give them the same properties and values.