1

I am do something here .

class A {
  constructor(name) {
    this.name = name;
  }

  getName() {
    return this.name;
  }
}

class B {
  alertError(error) {
    alert(error);
  }
}

class C extends(A, B) {
  constructor(name) {
    super(name);
  }

  welcome() {
    alert("Hai Welcome To My App !..");
  }

}

var ins1 = new C("Test");
ins1.welcome();
console.log(ins1.getName());

I access parent A method it throw error.C class access Parent 'B'.I can't be access to Parent 'A'.Why it do that ?

Barmar
  • 669,327
  • 51
  • 454
  • 560
Obeth Samuel
  • 591
  • 1
  • 5
  • 18
  • 1
    I was about to post an answer to explain why this doesn't work. While the duplicate answers at a high level, it doesn't really clarify why there's a runtime error here instead of a `SyntaxError`, for example. `extends` is a keyword, not a function, and so `(A, B)` invokes the [comma operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator), which effectively reduces the statement to `class C extends B {...}` – Patrick Roberts Jan 17 '18 at 19:50

0 Answers0