Explore whether javascript is an object oriented language

  • 2020-03-29 23:56:51
  • OfStack

It has objects that can contain data and methods to process it. Objects can contain other objects. It doesn't have classes (before javascript2.0 was actually implemented), but it does have constructors that do what classes do, including containers and roles that act as variables and methods. It doesn't have class-based inheritance, but it does have prototype-based inheritance. Two ways to set up an object system are through inheritance and through aggregation. JavaScript has both.

3 say javascript is a language based on object, is a kind of right and wrong is slightly conservative judgment, and that javascript is not object-oriented, in my opinion is the wrong cognition, there are plenty of reasons to prove that javascript is an object-oriented language, only compared with the traditional class-based object-oriented, javascript has its distinctive place, this uniqueness we call it based on the object-oriented prototype.

-----------------------------------------

JS is not object oriented. It is not object oriented. It can also be written as classes, methods, properties. But it is a little different from other languages! Such as
Var CLS = {
My: {a: 0}.
Init: function ()
{
  Alert (enclosing my. A);
}
};
Window. The onload = function ()
{
CLS. The init ();
}

Call the CLS. The init ();

This is his class, but it lacks a lot of object-oriented features. So it's not completely object oriented

Object orientation is just a way of thinking a way to solve the problem!


Related articles: