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 trialtal Shnitzer
Courses Plus Student 5,242 Pointswhat is the advantage of using "class" over constructor functions ?
I coded the same stuff that was coded to the class constructor, into the constructor function. with same results
1 Answer
Steven Parker
231,236 PointsThe syntax itself is the difference. People already familiar with other languages often find the new syntax easier to use than the traditional prototypical syntax of JavaScript.
On the other hand, I saw a video lecture by famous JavaScript scholar Douglas Crockford where here said he still prefers to use the traditional syntax because it more accurately reflects what's happening "under the hood".
Teacher Russell
16,873 PointsTeacher Russell
16,873 PointsIn the long run, I think we'll find that it's easier to read, simpler to write, and less error prone where inheritance is concerned. All of the previous syntax is legal, though, right, so it's up to you and your needs. I'm just starting with it, but that's the impression I've gotten.