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) Practice Project Project Overview

ES6 Classes

How safe is to start using ES6 classes instead of ES5 prototypes.

Since this is going to be the future, is it OK to start developing projects using classes?

Thanks!

2 Answers

Ari Misha
Ari Misha
19,323 Points

Hiya there! I think i can agree with all the developers who says JavaScript feels like a different language now. But now it feels more powerful , versatile and developer friendly. You can only feel it if you're moving to JavaScript from Ruby or Python. I love Python and Ruby when it comes to creating flexible Algorithms which on some level JavaScript cant achieve yet. But i can see where JS community wants to see JS in future.

Since i moved to JavaScript from Ruby, i prefer class implementation of OOP in JS. But behind the scenes, it still works as prototypal inheritance. But i wouldnt prefer prototypal inheritance . not coz i moved to JS from other languages, its coz class implementation feels like more organized , best practices and less redundant. Also if you look at libraries or frameworks like React or Vue , they have implemented class syntax in their docs. So yeah i hope it helped!

~ Ari

That's right but would you say it is safe to develop using classes without the need to transpile the code before running it?

Ari Misha
Ari Misha
19,323 Points

Kiril Kostov Well thats an interesting question. Well most of the browsers are compatible with most of the ES6 features , but not all. But why wouldnt you transpile your code? Babel is an amazing feature with a lots of functionalities. BUT Babel only transpiles your code. So you cant be depend on Babel all the time. There are other options as well. But i'd rather use Babel + Polyfill. Second is using TypeScript. But then you're gonna have to learn whole other language called TypeScript. I actually use ES7 implementation with my projects but with tools like Webpack and ESLint. You cant escape using tools like Babel or webpack or eslint or AirBnB/enzyme etc.,

~ Ari

I am from a Java / C# / C++ background, I get prototyping, it makes sense, it's not my first choice though, where I can, I will be using classes in my production code even though classes are syntactic sugar in Js.

Interesting approach though.