JavaScript PolymorphismThe polymorphism is a core concept of an object-oriented paradigm that provides a way to perform a single action in different forms. It provides an ability to call the same method on different JavaScript objects. As JavaScript is not a type-safe language, we can pass any type of data members with the methods. JavaScript Polymorphism Example 1Let's see an example where a child class object invokes the parent class method. Test it NowOutput: A is invoked Example 2Let's see an example where a child and parent class contains the same method. Here, the object of child class invokes both classes method. Test it NowOutput: A is invoked B is invoked Example 3Let's see the same example with prototype-based approach. Test it NowOutput: A is invoked B is invoked
Next TopicJS Abstraction
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week