官术网_书友最值得收藏!

Is JavaScript Object Oriented?

Once we have established the principles commonly accepted for defining a language as Object Oriented, can we affirm that JavaScript is an OOP language? Many developers do not consider JavaScript a true object-oriented language due to its lack of class concept and because it does not enforce compliance with OOP principles.

However, we can see that our informal definition make no explicit reference to classes. Features and principles are required for objects. Classes are not a real requirement, but they are sometimes a convenient way to abstract sets of objects with common properties. So, a language can be Object Oriented if it supports objects even without classes, as in JavaScript.

Moreover, the OOP principles required for a language are intended to be supported. They should not be mandatory in order to do programming in a language. The developer can choose to use constructs that allow him to create Object Oriented code or not. Many criticize JavaScript because developers can write code that breaches the OOP principles. But this is just a choice of the programmer, not a language constraint. It also happens with other programming languages, such as C++.

We can conclude that a lack of abstract classes and leaving the developer free to use, or not features that support OOP principles are not real obstacle to consider JavaScript an OOP language. So, let's analyze in the following sections how JavaScript supports abstraction and OOP principles.

主站蜘蛛池模板: 桦川县| 阳江市| 遵化市| 巨鹿县| 乡宁县| 尤溪县| 林西县| 浦县| 衢州市| 井研县| 巴楚县| 夏河县| 洛川县| 卓资县| 沁水县| 武威市| 方正县| 泾源县| 衡南县| 高陵县| 卓尼县| 互助| 舒兰市| 泉州市| 监利县| 吴桥县| 织金县| 克什克腾旗| 潼关县| 韶山市| 富宁县| 普格县| 青田县| 巴马| 保德县| 远安县| 上虞市| 通州区| 汉中市| 珲春市| 和龙市|