Wednesday, 25 December 2013

Calling a function from another function in JavaScript

Calling a function from another function In JavaScript. Let see How to call Function with another function.

Code For Calling a function from another function in JavaScript

Calling a function from another function
Calling a function from another function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<html>
<head>
</html>
<body>
 
<script type="text/javascript">
function doFirst() {
 document.write("I am First Function!");
}
function doSecond() {
 document.write("I am Second Function");
}
 
function start(){
 doFirst();
 doSecond();
}
start();
</script>
 
</body>
</html>
Output Screenshot
Calling a function from another function
Calling a function from another function (Screenshot2)
Firstly I had function name doFirst which i will called first inside the function. Now in First function I just echo out message on screen I am first means when ever i will call function it will echo me I am first Function. Then had a second function with message I am second function.Then I had function start which will call functions.
function start(){
doFirst();
doSecond();
}
The Above Code is declaration how we can declare function with another function or can also call function inside function in JavaScript.
Then we had call start(); We defined function which will call our doFirst Function Then it will call doSeond function In Such a way in JavaScript we can call function inside the function. Or calling function with another function in JavaScript.

No comments:

Post a Comment