DEV Community

Discussion on: Do you really understand interfaces?

Collapse
 
whiplash5057 profile image
Richard Andrews

Great read. Love the analogies. But I'm a javascript developer and there is no support for interfaces in javascript currently. How would I create a contract for other developers to follow?

Collapse
 
gaurang847 profile image
Gaurang

That's a nice question!
You're right. JavaScript is not strongly an object-oriented language and it does not have interfaces. And AFAIK, there's no real way of creating a contract like that in JavaScript.

Also, JavaScript is not statically-typed. So, even if you had interfaces, you could only check for the existence of functions. And not for their return-types or their parameters.
You may use TypeScript though. It supports interfaces, type-checking and works with existing JS code.