+ 2

Does javascript support data encapsulation, polymorphism as other objetct oriented programming language

6th Apr 2018, 2:41 PM
Manuel Nuel
2 Answers
+ 2
Yes, support something like oop. Does not have classes with methods, but you can simulate it by functions.
6th Apr 2018, 3:16 PM
Damyan Petkov
Damyan Petkov - avatar
+ 2
It depends on the version. In versions of Ecmascript (padrĂŁo JavaScript) below 6 you can simulate OOP with objects, functions and the prototype pattern. In Ecmascript 6 we have new features that support OOP, mainly classes. Many browsers don't support Ecmascript 6 yet, and that's why people continue using legacy code. But you can use Babel for translating this new version of JavaScript code to legacy code, in your projects. Read more: Babel: https://babeljs.io Classes (Ecmascript 6): http://es6-features.org/#ClassDefinition
6th Apr 2018, 6:13 PM
Maicon Mauricio
Maicon Mauricio - avatar