javascript functions:

Function Declaration:

You can define a function using the function keyword. Parameters are optional, and the code inside the curly braces is the function’s body.

Function Expression:

Function expressions create anonymous functions and assign them to variables. They can be named as well.

Arrow Functions:

Arrow functions provide a more concise syntax for function expressions, especially when the function body is a single expression.

Function Invocation:

You can invoke (call) a function by using its name followed by parentheses. Arguments are passed inside the parentheses.

Return Statement:

Functions can return a value using the return statement. If no return statement is present, the function returns undefined

Parameters and Arguments:

Parameters: These are placeholders in the function declaration.

Scope:

Functions have their own scope, and variables defined inside a function are typically not accessible outside of it.

Anonymous Functions:

Functions can be created without a name. They are often used as arguments to other functions or for immediate invocation.

Callback Functions:

Functions can be passed as arguments to other functions. These are known as callback functions.

Function Hoisting:

Function declarations are hoisted in JavaScript, meaning they can be called before they are declared in the code.

Leave a Reply