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
Omar Farag
4,573 PointsWhat does the keyword 'new' do in JS?
I was doing a challenge and it wanted me to type the word 'new' before a variable.
What does 'new' do?
2 Answers
Jennifer Nordell
Treehouse TeacherIt creates a new instance of an object.
jason chan
31,009 Pointsfunction Course(name, gradingareas, finalgrade) {
this.name = name;
this.gradingareas = gradingareas;
this.finalgrade = finalgrade;
}
var course1 = new Course("CS1500", gradingareas, 85);
This is object oriented programming. Basically create a blueprint of a class, then create a new course it will always have the same guidelines like this name, grade area, and final grade.
You can do it for car. Like for example every car has a name, color, 4 tires. It takes time to understand.
Omar Farag
4,573 PointsOmar Farag
4,573 PointsInstance of an object? Could you please explain that? Thanks in advance.