Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Andy Simmons
Andy Simmons
Courses Plus Student 3,734 Points

How to augment and avoid over writing an object that's being passed into a module

I just watched https://teamtreehouse.com/library/the-module-pattern-in-javascript

At about 10:55, an object is passed into the module, if it exists, otherwise an empty object.

Assuming the object being passed in exists, the code in the module is assigning a completely new object to the object reference. This means the passed in object has been over written with a totally new object.

Just a bit concerned about this and whether further checks should be made whether to augment the object with properties if it exists otherwise to assign it a new object.