原型继承

2018-04-23 14:04:00
admin
原创
304
<!DOCTYPE html>
<html>
<head>
    <title>原型继承</title>
</head>
<body>
    <p>原型继承</p>
    <script type="text/javascript">
        function Person(name,age,email) {  
            this.user_name = name;  
            this.user_age = age;  
            this.user_email = email;  
  
        }  
        Person.prototype.sayHi=function(){  
            alert (this.user_name+'    '+this.user_age+'   '+this.user_email);  
        }  
        var p1=new Person('ss',18,'ss@163.com');  
        p1.sayHi();  
        function student(sid) {  
            this.user_ID = sid;  
        }  
        student.prototype = p1;  
        var s1 = new student(001);  
        s1.user_name = 'sss';  
        s1.user_age = 10;  
        s1.sayHi();  

    </script>
</body>
</html>
				
				
文章分类
联系我们
电话: 18902328227
Email: 2689701946@qq.com
QQ: 2689701946
微信: 18902328227
地址: 广州番禺区繁华路
  • 在线客服
  • 关注微信
  • 联系电话
    • 欢迎咨询
    • 欢迎加入QQ群 303257430
  • 公众号:源宝网络
    • 联系电话及微信号 18902328227