Javascript-OOPs(Part4)-Polymorphism- (10)
👉 Javascript with OOPs (Polymorphism) Polymorphism is possible only with strongly typed languages, we cannot implement it in Javascript since we cannot declare strongly typed variables, and datatypes of variables are decided at runtime. We have achieved a bit of polymorphism while implementing inheritance, where in "cust" object first refers to the "Customer" class and then to the "CustomerChild" class, but still direct polymorphism is not available. Javascript variables are dynamic and they are created based on the datatype of the right-hand side value. To summarize: 1)You can create a class by using a function. You have a new keyword to create an instance. 2)You can define private and public methods by using/not using the "this" keyword. 3)Function inside a function is a closure. Closures are the core while implementing classes and objects in javascript. 4)Use Closures to create private methods, if you want to expose the method use "th