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

M Glasser
M Glasser
10,868 Points

What makes something a "true" object oriented language?

Guil mentions that JavaScript is not a "true" object oriented language, like e.g. Java.

What does he mean exactly?

What things can't you do with JavaScript that you can with a "true" OOP language?

1 Answer

Steven Parker
Steven Parker
231,269 Points

The classic definition is that there are 4 major principles that make a language object-oriented: Encapsulation, Data Abstraction, Polymorphism and Inheritence.

Some people consider that since JavaScript's objects use a prototype paradigm rather than the more common class paradigm disqualify it, but that's not universally agreed. And the argument isn't so much about what you can do, but how it is done since the approach can be quite different in the two paradigms. Nothing in the formal classic definition says the language must use classes.

Recent language additions (ES2015/ES6) have closed the gap bit by introducing keywords and syntax much like class-paradigm languages, but there still are differences including the lack of abstract classes.

Another common complaint is that JavaScript does not enforce object-oriented constructs. The developer can choose to use constructs that allow him to create object-oriented code or not. But I woud think the fact that you have the ability to create object-oriented code is more important than if the language itself is "truly" object-oriented.