?
Solved

Java Script nested call

Posted on 2016-08-08
3
Medium Priority
?
116 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
Moore’s Law has proven itself time and time again since it was first introduced. So what’s next? Will Moore’s law continue to remain relevant, or will new technology take over and bring us the next big advancement in computing?
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

807 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