Don't Understand Constructor and super in javascript

I was reading inheritance in javascript but couldn’t understand constructor function because it is written in a different way in different places. Such as,

constructor(…args) {
super(…args) = 20
What’s the meaning of “…args” in the code above?

But in some places it is written like
constructor() {
Why use no parameter inside the constructor and super?
why we use “…args” sometimes and use no parameter sometimes inside the constructor and super? What’s the difference between the two approaches?


…args` denotes arguments. Just like you could pass parameters into a function. Constructor is a function anyway

I don’t have much details about this code. But it’s possible that you call a function that expects argument(s) without passing one or the amount required into it - JavaScript is flexible.

You call super() when a class with a constructor extends another class(the constructor is not automatically called). An error is thrown if you use the this before calling super(). Super() calls the constructor function of the parent class. If the child class has no constructor, the parent class constructor is called automatically anyway.

there’s also super.method() – useful sometimes

I suggest you read up functions - a constructor is a function (constructor function).