Solved

Java Script nested call

Posted on 2016-08-08
3
86 Views
Last Modified: 2016-08-08
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?
0
Comment
Question by:sakthikumar
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
Gauthier earned 500 total points
ID: 41747311
cta = new call1();
should be
this.cta = new call1();
0
 

Author Closing Comment

by:sakthikumar
ID: 41747358
Excellent Thanks:)
0
 

Author Comment

by:sakthikumar
ID: 41748255
Hi Gauthier,

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

Thanks,
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Apache-Tomcat Single Sign On with NTLM/Kerberos on Windows 2008R2 3 229
getting param value 7 57
maven project jars 7 55
How can I   ajax html table  rows? 20 78
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question