-1

Is there any possible way to achieve the abstraction in JavaScript world like we have in OOPS?

The abstract class will serve as base and we will create concrete components out of it. And how to implement the interfaces concepts in JavaScript?

Pang
  • 9,564
  • 146
  • 81
  • 122
Gowthaman
  • 790
  • 1
  • 10
  • 29
  • 1
    this might inform you well: https://stackoverflow.com/questions/3710275/does-javascript-have-the-interface-type-such-as-javas-interface – Emtiaz Zahid Nov 20 '18 at 06:11

1 Answers1

1

It makes little sense to have interfaces or abstract classes, as there are no typechecks.:

 function fn(sth) { console.log(sth.age); }

 fn(new Person());
 fn(new Animal());

If you want typechecks, including interfaces, use TypeScript

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151
  • ["Abstract classes"](https://stackoverflow.com/q/29480569/1048572) could still be used for sharing behaviour (and supporting `instanceof`). Of course, mixins could solve most problems just as well. – Bergi Nov 20 '18 at 07:48