Link to home
Start Free TrialLog in
Avatar of sakthikumar
sakthikumar

asked on

Java Script nested call

Hi,

I am learning javascript, trying out the below code, it is not working.
Just wanted to check if the below is feasible.

<html>
<script type = 'text/javascript'>
function call1()
{
this.c = 10;
document.write("call done");
}
function call2()
{
cta = new call1();
//document.write("call2"+cta.c);
}
function execute(){
var abc = new call2();
document.write(abc.cta.c); // can I do like this. if this is wrong any other way.

}
</script>
<body>
<input type = button onclick = "execute()"/>
</body>
</html>
--------------------------------------------
I have created a function "call1". This has a variable "C".
, and created an object for it in another function "call2"
then created a function "execute" to create an object for "call2"
now wanted to access the variable "C" in "call1" through "call2"

Is it possible to do like that?
ASKER CERTIFIED SOLUTION
Avatar of Gauthier
Gauthier

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sakthikumar
sakthikumar

ASKER

Excellent Thanks:)
Hi Gauthier,

If you could give me the reason for this, it would be very helpful to me.

Thanks,