How to implement interface in javascript

Javascript

Javascript Problem Overview


Is it possible to implement interface in javascript

if yes do you have any example ?

Javascript Solutions


Solution 1 - Javascript

First of all, there is not built in support for traditional abstraction in JavaScript. At least, there are not any types like interfaces and abstract classes. However, interface can be implemented using Object.create method and prototypes. For more information, visit here.

Solution 2 - Javascript

Quoting from an article written by Mark McDonnell:

> In JavaScript there are no true "classic" Object-Oriented features, > but through clever usage of the language you can emulate an Interface > for use with a JavaScript API.

See the following for the complete article:

http://www.javascriptbank.com/how-implement-interfaces-in-javascript.html

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1365697View Question on Stackoverflow
Solution 1 - JavascriptyusufaytasView Answer on Stackoverflow
Solution 2 - JavascriptPraveenVenuView Answer on Stackoverflow