0% found this document useful (0 votes)
3 views1 page

JavaScript Polymorphism Example

The document provides an example of polymorphism in JavaScript through a series of class definitions and method overrides. It demonstrates how classes A_class, B_class, and C_class each implement their own version of the method m1, which outputs different text to the document. Additionally, it includes an interview question section related to JavaScript, though details of the questions are not provided.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

JavaScript Polymorphism Example

The document provides an example of polymorphism in JavaScript through a series of class definitions and method overrides. It demonstrates how classes A_class, B_class, and C_class each implement their own version of the method m1, which outputs different text to the document. Additionally, it includes an interview question section related to JavaScript, though details of the questions are not provided.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Polymorphism in JavaScript:

===================

Ex1:
==
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript_Session</title>
</head>
<body>
<script>
class A_class
{
m1()
{
[Link]("This is A_class")
[Link]("<hr>")
}
}
class B_class extends A_class
{
m1()
{
[Link]("This is B_class")
[Link]("<hr>")
}
}
class C_class extends B_class
{
m1()
{
[Link]("This is C_class")
[Link]("<hr>")
}
}
var obj1 =[new A_class(),new B_class(),new C_class()]
[Link](function(X1){
X1.m1()
})

</script>

</body>
</html>

Interview_Question on JavaScript:
=======================

You might also like