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! While you're at it, check out some resources Treehouse students have shared here.

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

JavaScript

New Operator

Can someone explain the New operator? I find it very confusing. The teacher uses it but she hasnt explained what it does.

1 Answer

Steven Parker
Steven Parker
243,266 Points

The "new" operator is for creating an object. It makes an empty generic object and passes it to the constructor function (which you will place right after it). The constructor function can then reference the object being constructed by using the keyword "this".

For more details, see the MDN page on "new".