How many ways are there to call a function in a program? Explain with example?
Two Ways of Calling Functions: Functions do not run automatically. While the page loads, every function waits quietly until it is told to run.
1. A function calls appearing as a totally completed statement:
function popUp( message ) {
window.alert( message ) ;
}
popUp( "Warning!" ) ;
2. A function calls appearing as part of a statement. Definitions of like functions involve a ‘return' statement:
function add( a, b ) {
c = a + b ;
return c ;
}
sum = add( 2, 4 ) ;
document.write( sum ) ;