I am facing an issue with storing the instance of a Child class in a parent variable. Even after doing so, I find that when trying to call the Child's functions using the parent variable, it does not work as expected. How can I effectively utilize the Child functions in this scenario?
class Parent{
public teach(){
console.log("Parent teaching");
}
}
class Child extends Parent{
public learn(){
console.log("Child Learning");
}
}
Parent x = new Child();
x.learn(); //Attempting to call Child function from Parent variable