JavaScript objects are prototype-based, not class-based. It is a more generic model:
Object).Nonetheless, words like class and similar are frequently used as synonyms for prototype, etc.
var A = class {
a = 123;
b;
sum() {
return this.a + this.b;
};
};
print(new A(), true);
typeof(A.prototype.sum)
"function"
var o = new A(); o.b = 77; print(o.sum());
var B = class extends A {
constructor(val) {
super();
this.b = val;
}
};
print(new B(77), true);
The console allows you to interact with the course material and examples. Use the following keys:
A special logging function is also available: