Recently I started thinking about OOP in Javascript. Having been heavily involved in functional React for the last 2.5 years it wasn’t easy.
You know basic OOP concepts are: encapsulation, inheritance, abstraction, and polymorphism. I have been looking at a good example of **polymorphism **in Javascript.
In dynamic languages, it exists in the form of duck typing. Duck what?
If something quacks like a duck, it is a duck.
Polymorphism is when a different function gets called depending on the type of objects on which that function is executed. So is it a duck? Call the duck() function! Is it a dog? Call the dog() one!
#javascript