functionRange (from,to,x) {//instance (object) field This. x=x;}//class fieldRange.y= "class field";//class Methodrange.s=function(){ return' Class method ';}; Range.prototype={constructor:range,//instance MethodSlff:function(){ return"Instance method"; }};vars=NewRange (1, 3, instance field)); Console.log (s.x); Console.log (S.slff ()); Console.log (RANGE.Y); Console.log (RANGE.S ()); Console.log (SinstanceofRange);
Constructor Object (Range)
A constructor (object) defines a name for a JavaScript class. Any addition to this constructor object
Properties are class fields and class methods (the class method if the property value is a function).
Prototype Object (Range.prototype)
The properties of the prototype object are inherited by all instances of the class, and if the property value of the prototype object is a function, the function
Called as a method of an instance of a class.
Instance Object (new Range ())
Each instance of the class is a separate object, and the attribute defined directly to the instance is not for all instances
Objects that are shared by the. Defines a non-function property on the instance that is actually the field of the instance.
Java-class members in JS