JavaScript Introducing ES2015 Classes Structure of Class

tal Shnitzer
PRO
tal Shnitzer
Pro 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,866 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
170,320 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".