Calling a function from another function

A function can be call within another function. In this way it is easier to control and organize the sequence in which your events will occur.

function Update_MyAlertBox() {
    window.alert("This is an update!");

function TheCallerAlert() {


The real action happens in the first function Update_MyAlertBox(). The second function, TheCallerAlert(), just calls the first function. The second function is not executed until it is called, which happens on the last line of code. This is what starts the whole sequence.

If you want to have three functions that perform three tasks then you can create the forth function that calls them in the desired order.

function TheAlertOne() {
    window.alert("Welcome. This is my site!");

function TheAlertTwo() {
    window.alert("Let's get in touch. Visit contact page.");

function TheAlertThree() {
    window.alert("You can also visit my photo album.");

function GetOrderedResult() {

First, I defined the three functions, one for each alert I want to show. The fourth function is an ordered call for the previously created three functions. The last line is the call for the fourth function which is a call for the other three.

Leave a Reply