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 Introducing ES2015 Classes Structure of Class

tal Shnitzer
PLUS
tal Shnitzer
Courses Plus Student 5,242 Points

what 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

Teacher Russell
Teacher Russell
16,873 Points

In 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.

1 Answer

Steven Parker
Steven Parker
231,275 Points

The 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".