Skip to content

Commit 518a249

Browse files
committedJul 8, 2024
chore: Update JavaScript data types, variables, and concepts in README.md
1 parent f83e382 commit 518a249

File tree

1 file changed

+52
-22
lines changed

1 file changed

+52
-22
lines changed
 

‎README.md

+52-22
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ This repository contains a list of JavaScript concepts, functions, methods, and
5555
- [Block Scope](#block-scope)
5656
- [Function Scope](#function-scope)
5757
- [Global Scope](#global-scope)
58+
- [Hoisting](#hoisting)
59+
- [Currying](#currying)
5860
- [Dates](#dates)
5961
- [Date Methods](#date-methods)
6062
- [Date Get Methods](#date-get-methods)
@@ -73,14 +75,15 @@ This repository contains a list of JavaScript concepts, functions, methods, and
7375
- [Set Methods](#set-methods)
7476
- [Map](#map)
7577
- [Map Methods](#map-methods)
78+
- [Recursion](#recursion)
7679
- [Async](#async)
7780
- [DOM](#dom)
7881
- [Browser BOM](#browser-bom)
7982
- [JSON](#json)
8083
- [Web API](#web-api)
8184
- [Ajax](#ajax)
8285
- [jQuery](#jquery)
83-
- [Graphocs](#graphics)
86+
- [Graphics](#graphics)
8487
- [Best Practices](#best-practices)
8588
- [Common Mistakes](#common-mistakes)
8689
- [Performace](#performance)
@@ -1885,6 +1888,34 @@ console.log(a);
18851888
18861889
[Back to Top⤴️](#table-of-contents)
18871890
1891+
## Hoisting
1892+
1893+
Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their containing scope during the compilation phase.
1894+
1895+
```javascript
1896+
console.log(x); // Output: undefined
1897+
1898+
var x = 5;
1899+
```
1900+
1901+
[Back to Top⤴️](#table-of-contents)
1902+
1903+
## Currying
1904+
1905+
Currying is a technique in which a function with multiple arguments is converted into a sequence of nested functions, each taking a single argument.
1906+
1907+
```javascript
1908+
function multiply(a) {
1909+
return function(b) {
1910+
return function(c) {
1911+
return a * b * c;
1912+
};
1913+
};
1914+
}
1915+
1916+
console.log(multiply(2)(3)(4)); // Output: 24
1917+
```
1918+
18881919
## Dates
18891920
18901921
JavaScript provides a built-in Date object that can be used to work with dates and times.
@@ -1897,6 +1928,8 @@ The Date object is used to work with dates and times in JavaScript. It can be cr
18971928
new Date()
18981929
```
18991930
1931+
[Back to Top⤴️](#table-of-contents)
1932+
19001933
### Date Formats
19011934
19021935
There are several ways to create a new Date object in JavaScript:
@@ -2699,6 +2732,24 @@ fruits.size;
26992732
27002733
[Back to Top⤴️](#table-of-contents)
27012734
2735+
## Recursion
2736+
2737+
Recursion is a programming technique where a function calls itself in order to solve a problem. Recursion is used to solve problems that can be broken down into smaller, more manageable subproblems.
2738+
2739+
```javascript
2740+
function factorial(n) {
2741+
if (n === 0) {
2742+
return 1;
2743+
} else {
2744+
return n * factorial(n - 1);
2745+
}
2746+
}
2747+
2748+
factorial(5); // 120
2749+
```
2750+
2751+
[Back to Top⤴️](#table-of-contents)
2752+
27022753
## Async
27032754
27042755
Asynchronous programming allows you to run multiple tasks concurrently without blocking the main thread. JavaScript provides several ways to work with asynchronous code, including callbacks, promises, and async/await.
@@ -2742,27 +2793,6 @@ myPromise.then((value) => {
27422793
// Output: The async operation was successful
27432794
```
27442795
2745-
### Callback function
2746-
2747-
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
2748-
2749-
```javascript
2750-
function myDisplayer(some) {
2751-
document.getElementById("demo").innerHTML = some;
2752-
}
2753-
2754-
function myCalculator(num1, num2, myCallback) {
2755-
let sum = num1 + num2;
2756-
myCallback(sum);
2757-
}
2758-
2759-
myCalculator(5, 5, myDisplayer);
2760-
2761-
// Output: 10
2762-
```
2763-
2764-
[Back to Top⤴️](#table-of-contents)
2765-
27662796
### Promise
27672797
27682798
A promise is an object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.

0 commit comments

Comments
 (0)
Failed to load comments.