class
Defination
The class declaration creates a new class with a given name using prototype-based inheritance.
Syntax
class name [extends] {
// class body
}Examples
class Polygon {
constructor(height, width) {
this.name = 'Polygon';
this.height = height;
this.width = width;
}
}
class Square extends Polygon {
constructor(length) {
super(length, length);
this.name = 'Square';
}
}Usage
Example from react.
References
Last updated
Was this helpful?