Skip to content

Commit 13a5438

Browse files
committed
chore: Update README.md with new function types and examples
1 parent 43bd186 commit 13a5438

File tree

1 file changed

+78
-31
lines changed

1 file changed

+78
-31
lines changed

README.md

Lines changed: 78 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ This repository contains a list of JavaScript concepts, functions, methods, and
5050
- [if else else if statement](#if-else-else-if-statement)
5151
- [switch statement](#switch-statement)
5252
- [Functions](#functions)
53-
- [Arrow Functions](#arrow-function)
53+
- [Named Function](#named-function)
54+
- [Anonymous Function](#anonymous-function)
55+
- [Arrow Functions](#arrow-function)
56+
- [Immediately Invoked Function Expression (IIFE)](#iife)
57+
- [Higher Order Function](#higher-order-functions)
58+
- [Function Declaration](#function-declaration)
59+
- [Function Expression](#function-expression)
60+
- [Function Constructor](#function-constructor)
5461
- [Scope](#scope)
5562
- [Block Scope](#block-scope)
5663
- [Function Scope](#function-scope)
@@ -2353,6 +2360,11 @@ function name(parameter1, parameter2, parameter3) {
23532360
- Named Function
23542361
- Anonymous Function
23552362
- Arrow Function
2363+
- IIFE
2364+
- Higher-Order Function
2365+
- Function Expression
2366+
- Function Declaration
2367+
- Function Constructor
23562368
23572369
[Back to Top⤴️](#table-of-contents)
23582370
@@ -2406,6 +2418,71 @@ const name = () => {
24062418
24072419
[Back to Top⤴️](#table-of-contents)
24082420
2421+
## IIFE
2422+
2423+
An IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as soon as it is defined.
2424+
2425+
```javascript
2426+
(function() {
2427+
console.log("Hello World!");
2428+
})();
2429+
```
2430+
2431+
[Back to Top⤴️](#table-of-contents)
2432+
2433+
## Higher-Order Functions
2434+
2435+
A higher-order function is a function that takes another function as an argument or returns a function as a result.
2436+
2437+
```javascript
2438+
function greet() {
2439+
return "Hello World!";
2440+
}
2441+
2442+
function greetUser(greet) {
2443+
return greet();
2444+
}
2445+
2446+
console.log(greetUser(greet)); // Output: "Hello World!"
2447+
```
2448+
2449+
[Back to Top⤴️](#table-of-contents)
2450+
2451+
## Function Expression
2452+
2453+
A function expression is a function that is assigned to a variable.
2454+
2455+
```javascript
2456+
const greet = function() {
2457+
return "Hello World!";
2458+
}
2459+
2460+
console.log(greet()); // Output: "Hello World!"
2461+
```
2462+
2463+
## Function Declaration
2464+
2465+
A function declaration is a function that is defined using the function keyword followed by the function name.
2466+
2467+
```javascript
2468+
function greet() {
2469+
return "Hello World!";
2470+
}
2471+
2472+
console.log(greet()); // Output: "Hello World!"
2473+
```
2474+
2475+
### Function Constructor
2476+
2477+
A function constructor is a function that is used to create new objects.
2478+
2479+
```javascript
2480+
const greet = new Function("return 'Hello World!'");
2481+
console.log(greet()); // Output: "Hello World!"
2482+
```
2483+
2484+
[Back to Top⤴️](#table-of-contents)
2485+
24092486
## Scope
24102487
24112488
Scope refers to the visibility of variables in JavaScript. There are three types of scope in JavaScript:
@@ -2512,36 +2589,6 @@ function multiply(a) {
25122589
console.log(multiply(2)(3)(4)); // Output: 24
25132590
```
25142591
2515-
## IIFE
2516-
2517-
An IIFE (Immediately Invoked Function Expression) is a JavaScript function that runs as soon as it is defined.
2518-
2519-
```javascript
2520-
(function() {
2521-
console.log("Hello World!");
2522-
})();
2523-
```
2524-
2525-
[Back to Top⤴️](#table-of-contents)
2526-
2527-
## Higher-Order Functions
2528-
2529-
A higher-order function is a function that takes another function as an argument or returns a function as a result.
2530-
2531-
```javascript
2532-
function greet() {
2533-
return "Hello World!";
2534-
}
2535-
2536-
function greetUser(greet) {
2537-
return greet();
2538-
}
2539-
2540-
console.log(greetUser(greet)); // Output: "Hello World!"
2541-
```
2542-
2543-
[Back to Top⤴️](#table-of-contents)
2544-
25452592
## Dates
25462593
25472594
JavaScript provides a built-in Date object that can be used to work with dates and times.

0 commit comments

Comments
 (0)