


Batch implementation of object-oriented example code_javascript skills
May 16, 2016 pm 05:30 PM<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Batch implementation of object-oriented instances</title>
<script type="text/javascript ">
window.onload = function(){
function Person(name,age){
this.name = name;
this.age = age;
}
Person.prototype.showName = function(){
alert(this.name);
};
function extend(parent,child,method){
function a(){
parent .apply(this,arguments);
child.apply(this,arguments);
};
for(var i in parent.prototype){
a.prototype[i]=parent. prototype[i];
}
for(var i in method){
a.prototype[i] = method[i];
}
return a;
}; //The parameters are parent constructor, child constructor, child method
var int = extend(Person, function(name, age, job){
this.job = job;
},
{
showjob:function(){
alert(this.job);
}
}
);
var oc=new int('Xia Ke',24 ,'job');
oc.showjob();
}
</script>
</head>
<body>
<h1> for Object inheritance example</h1>
<p>Start showing examples of object-oriented implementation in batches</p>
</body>
</html>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of C++ function inheritance: How to use 'base class pointer' and 'derived class pointer' in inheritance?

How do inheritance and polymorphism affect class coupling in C++?

Detailed explanation of C++ function inheritance: How to debug errors in inheritance?

PHP Advanced Features: Best Practices in Object-Oriented Programming

Explore object-oriented programming in Go

Analysis of object-oriented features of Go language

C++ function inheritance explained: When should inheritance not be used?

Are there any class-like object-oriented features in Golang?
