52

Is it possible to implement interface in javascript

if yes do you have any example ?

0

2 Answers 2

19

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Using Object.create and prototypes actually simulates inheritance and not interfaces.
11

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

1 Comment

The link seems to be broken

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.