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 Object-Oriented JavaScript (2015) Prototypal Inheritance Updating the Song Object

Will JS one day have syntactic sugar equivalent to the Java method of specifying inheritance?

The prototype inheritance syntax is awkward to say the least. I hope at some point the makers of Javascript will add an extends or inherits keyword to the language so that the mechanism of inheritance becomes less unwieldy.

function childObject() {
   this.extends(parentObject); 
}

3 Answers

Good news Adiv -- more formal class / inheritance language features are rolled into the ECMAScript 6 standard! I think that's what you are hoping for?

ECMAScript 6 Features

Coming back to JavaScript after a lot of time developing in Java, I too really missed defining class relationships explicitly. Although flexible, the JavaScript way just seems sloppy in comparison.

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Adiv,

You might be interested in Typescript. Typescript "lets you write JavaScript the way you really want to". It compiles to plain Javascript. You can check it out here.

I hope this helps.

Agreed Joshua, great point!

When I started to dive deeper into the JavaScript language, I realized that applying the "Java mindset" wasn't doing me any favors. Classes are actually a topic of heated debate in the JavaScript community right now; some are against Classes being in the latest ECMAScript spec at all.

Prototypal inheritance, has a lot of advantages over Class-based inheritance in JavaScript. Although it might seem like a small difference at first glance, it's actually pretty huge.