You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+52-22
Original file line number
Diff line number
Diff line change
@@ -55,6 +55,8 @@ This repository contains a list of JavaScript concepts, functions, methods, and
55
55
-[Block Scope](#block-scope)
56
56
-[Function Scope](#function-scope)
57
57
-[Global Scope](#global-scope)
58
+
-[Hoisting](#hoisting)
59
+
-[Currying](#currying)
58
60
-[Dates](#dates)
59
61
-[Date Methods](#date-methods)
60
62
-[Date Get Methods](#date-get-methods)
@@ -73,14 +75,15 @@ This repository contains a list of JavaScript concepts, functions, methods, and
73
75
-[Set Methods](#set-methods)
74
76
-[Map](#map)
75
77
-[Map Methods](#map-methods)
78
+
-[Recursion](#recursion)
76
79
-[Async](#async)
77
80
-[DOM](#dom)
78
81
-[Browser BOM](#browser-bom)
79
82
-[JSON](#json)
80
83
-[Web API](#web-api)
81
84
-[Ajax](#ajax)
82
85
-[jQuery](#jquery)
83
-
-[Graphocs](#graphics)
86
+
-[Graphics](#graphics)
84
87
-[Best Practices](#best-practices)
85
88
-[Common Mistakes](#common-mistakes)
86
89
-[Performace](#performance)
@@ -1885,6 +1888,34 @@ console.log(a);
1885
1888
1886
1889
[Back to Top⤴️](#table-of-contents)
1887
1890
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
+
functionmultiply(a) {
1909
+
returnfunction(b) {
1910
+
returnfunction(c) {
1911
+
return a * b * c;
1912
+
};
1913
+
};
1914
+
}
1915
+
1916
+
console.log(multiply(2)(3)(4)); // Output: 24
1917
+
```
1918
+
1888
1919
## Dates
1889
1920
1890
1921
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
1897
1928
newDate()
1898
1929
```
1899
1930
1931
+
[Back to Top⤴️](#table-of-contents)
1932
+
1900
1933
### Date Formats
1901
1934
1902
1935
There are several ways to create a new Date object in JavaScript:
@@ -2699,6 +2732,24 @@ fruits.size;
2699
2732
2700
2733
[Back to Top⤴️](#table-of-contents)
2701
2734
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
+
functionfactorial(n) {
2741
+
if (n ===0) {
2742
+
return1;
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
+
2702
2753
## Async
2703
2754
2704
2755
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.
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
-
functionmyDisplayer(some) {
2751
-
document.getElementById("demo").innerHTML= some;
2752
-
}
2753
-
2754
-
functionmyCalculator(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
-
2766
2796
### Promise
2767
2797
2768
2798
A promise is an object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
0 commit comments