Java Script nested call


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

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

<input type = button onclick = "execute()"/>
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?
Who is Participating?
GauthierConnect With a Mentor Commented:
cta = new call1();
should be
this.cta = new call1();
sakthikumarAuthor Commented:
Excellent Thanks:)
sakthikumarAuthor Commented:
Hi Gauthier,

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

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.