Calling functions in JavaScript

In order to see a function in action you need to call it. A call to a function is simply the function name followed by a set of parentheses (with or without parameters). It has to end with a semicolon.

MyFirstFunction();

Notes:

  • Functions can be called anywhere in your script.
  • A function can be called inside another function.
  • The function definition should come in script before the function call which means that it is a good idea to place all of your function definitions as close to the beginning of the script as possible.

Leave a Reply