Skip to content

Latest commit

 

History

History
33 lines (20 loc) · 1.43 KB

File metadata and controls

33 lines (20 loc) · 1.43 KB

FUNCTIONS, METHODS & OBJECTS

What is Function?

Functions let you group a series of statements together to perform a specific task. If different parts of a script repeat the same task, you can reuse the function (rather than repeating the same set of statements).

function

How does functions work?

To create a function, you give it a name and then write the statements needed to achieve its task inside the curly braces. This is known as a function declaration.

Function-keyword Function-Name(){ function-body; }

  • parameters and arguments:

functions exchange information by means of parameters and arguments.

    • parameter : declaration within the parentheses following the function name in a function declaration or definition;
    • argument refers to any expression within the parentheses of a function call.
  • calling :

We say that a program or a section of code “calls” a function. This means that we want to execute the code in the function. A function may “return” a value. This means that the calling statement will receive some result from the function when the function execution is complete.

  • Return Value:

When you write a function you expect it to provide you with an answer, the response is known as a return value.

return