abhilashm86
September 28th, 2009, 08:14 AM
i tried using apply in order to use a method in more than one object, why does this stop executing further more statements?
<html>
<head>
<title>fun objs</title>
</head>
<script type="text/javascript">
function a(color1)
{
this.color=color1;
this.saycolor= function()
{
alert(this.color);
};
}
function b(color2, name2)
{
a.apply(this,arguments);
this.color=color2;
this.name=name2;
this.sayname==function () {
alert(this.name);
};
}
var obja=new a("red");
var objb=new b("black","sadgh");
obja.saycolor();
objb.saycolor();
objb.sayname();
</script>
</html>
objb.sayname();
this is not getting executed?
<html>
<head>
<title>fun objs</title>
</head>
<script type="text/javascript">
function a(color1)
{
this.color=color1;
this.saycolor= function()
{
alert(this.color);
};
}
function b(color2, name2)
{
a.apply(this,arguments);
this.color=color2;
this.name=name2;
this.sayname==function () {
alert(this.name);
};
}
var obja=new a("red");
var objb=new b("black","sadgh");
obja.saycolor();
objb.saycolor();
objb.sayname();
</script>
</html>
objb.sayname();
this is not getting executed?