日期:2014-05-16  浏览次数:20356 次

帮我理解下这段小白
function   Employee(name,   salary,   mySupervisor)
{
    this.name=name;                                
    this.salary=salary;
    this.supervisor=mySupervisor;
}

var   boss=new   Employee( "111 ",   200);  
var   manager=new   Employee( "222 ",   50,   boss);    
var   teamLeader=new   Employee( "Rose ",   50,   boss);    
 
alert(manager.supervisor.name+ "   is   the   supervisor   of   "+manager.name);
alert(manager.name+ "\ 's   supervisor   is   "+manager.supervisor.name);  

</script>

------解决方案--------------------
manager是Employee的对象,supervisor和name是Employee的属性,
manager.supervisor是boss对象,
所以manager.supervisor.name就相当于boss.name
而boss.name是111,manager.name是222
所以manager.supervisor.name就是111