course content

Course Content

Introduction to JavaScript

DefinitionDefinition

You should use the function keyword to create a new function. Also, you need to name this function and define arguments that the function should take:

The function definition structure:

  • the function keyword;
  • function name (should be in camelCase like variables);
  • arguments are in parentheses (());
  • code block in curly brackets ({}).

Arguments

Functions have their own data usage space. Arguments are literals passed to a function. The function uses these arguments as variables. Arguments disappear when the function finishes executing. Functions have their own data usage space.

To define arguments, you need to give a name to each argument:

If a function accepts multiple arguments, they must be separated by commas (,).

Note

Arguments are used like variables inside the function code block.

Function calling

To use a function, you should call it by parentheses (()) and give the arguments if a function expects it:

Section 6.

Chapter 2