I want to understand, once and for all, what and how, namely with the heirs of classes and methods? Suppose there is a class example
function example(){ this.init = function(name){ this.name = name; } this.sayName = function(){ alert(this.name); } } var ex = new example(); ex.init("Andy"); ex.sayName(); Everything is obvious here, there is no wisdom, an object of the example class is created, when calling the init method, the name of the object is set, when calling sayName name of the Alert is displayed.
How to create a descendant (instance, heir, even as it is difficult to describe correctly) of the example class, and override the method sayName , let it now does not print out the name with the Alert, but write it to the console ?