Very useful. js class usage
Class defines the common behaviors and methods of a class of things, while the instance is a specific implementation of the class. We also know that object-oriented programming has three important concepts: encapsulation, inheritance, and transition.
However, in the javascript world, all of these features do not seem to exist. Javascript is not an object-oriented language, but an object-based language. There are some interesting features, such as that everything in javascript is an object. Including strings, arrays, dates, numbers, and even functions www.2cto.com
Javascript itself does not support object-oriented features. It does not have an access controller and does not have a class keyword defined.
Use Javascript to define a class instead of a class.
Function class1 (){
// Define two attributes
This. x = 1;
This. y = 2;
// Define two methods
This. show = function (){
Alert ("x =" + this. x );
}
}
// Instantiate the object
Var a = new class1 ();
// Call attributes
Alert (a ["x"]);
// Call your own Method
Alert (a. show ());
From xweina's column