ECMAScript is an extension and support for object-oriented JavaScript through ECMA-262, a standardized scripting language.
Object-oriented languages have the ability to support the reuse of classes and methods and properties in classes, implementing inheritance in JavaScript can be done in a variety of ways, such as call (), apply (), phishing, prototype chain, each with its pros and cons, and the ability to inherit through some external libraries, such as Xbobject, Zinherit and so on.
To implement inheritance by object phishing:
1. <script type= "Text/javascript" >
2. Function Parent (pname) {
3. this.name = PName;
4. This.saymyname = function () {
5. Alert (this.name);
6.};
7.}
8.
9. Function Mother (pname) {
THIS.name = PName;
This.saymyname = function () {
Alert (this.name+ "Sex*y");
13.};
14.}
15.
function Child (Cname,cnumber) {
This.myface = Parent;
This.myface (CName);
Delete This.myface;
20.
This.myface = Mother;
This.myface (CName);
Delete This.myface;
24.
This.number = Cnumber;
This.saynumber = function () {
alert (This.number);
28.};
29.}
30.
var objp =new Parent ("Hidehai");
var objm =new Mother ("Hidewow");
var objc =new Child ("Hidelow", 3);
34.
Objp.saymyname ();
Objm.saymyname ();
Objc.saymyname ();
Objc.saynumber ();
</script>