Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 817 Bytes

Read06.md

File metadata and controls

22 lines (15 loc) · 817 Bytes

Functions

Definition :

A JavaScript function is a block of code designed to perform a particular task.

JavaScript Function method:

  • The name of the function.
  • A list of parameters to the function, enclosed in parentheses and separated by commas.
  • The JavaScript statements that define the function, enclosed in curly brackets, {...}.

Function Invocation

The code inside the function will execute when "something" invokes (calls) the function:

  • When an event occurs (when a user clicks a button)
  • When it is invoked (called) from JavaScript code
  • Automatically (self invoked)

calling The Function:

Calling the function actually performs the specified actions with the indicated parameters. For example, if you define the function square, you could call it as follows: square(5);