JavaScript面向对象技术

 最近在研究JavaScript面向对象方面的技术,偶然之间使用了下面这种方法来实现继承.
在IE6和IE7的测试,结果都能正确实现继承.
可我在网上却找不到有这样的做法,是不是这样做有什么不妥,还请高人指点!

重点是这句:Employee.prototype = Person.prototype

        function Person(name){
        
            
this.name = name;
            
        }

        
        Person.prototype 
= {
        
            say : 
function(){
            
                    alert(
this.name);
                }

        }

        
        
        
function Employee(name, salary){
        
            Person.call(
this, name);
            
this.salary = salary;
        
        }

        
        
//请问这句会有什么问题
        Employee.prototype = Person.prototype;
        
        Employee.prototype.showMeTheMoney 
= function(){
            
            alert(
"name: " + this.name + ", salary: " + this.salary);
        }

        
        
var BillGates = new Person("Bill Gates");
        
var SteveJobs = new Employee("Steve Jobs"1);
               
        
        BillGates.say();
        SteveJobs.say();
        SteveJobs.showMeTheMoney();
        
        
        alert(BillGates.say 
== SteveJobs.say);
原文地址:https://www.cnblogs.com/oxsir/p/1203502.html