File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Closures and Prototypal Inheritance
2
+
3
+ ## Functions are first class citizens
4
+
5
+ - Functions can be assigned to variables and properties of objects.
6
+
7
+ ``` javascript
8
+ const stuff = function () {};
9
+ ```
10
+
11
+ - You can pass functions as arguments into a function.
12
+
13
+ ``` javascript
14
+ function something (fn ) {
15
+ fn ();
16
+ }
17
+
18
+ something (function () {
19
+ console .log (" hi" );
20
+ }); // => 'hi'
21
+ ```
22
+
23
+ - You can return functions as values from other functions.
24
+
25
+ ``` javascript
26
+ function a () {
27
+ return function b () {
28
+ console .log (" bye" );
29
+ };
30
+ }
31
+
32
+ a ()(); // => 'bye'
33
+ ```
34
+
35
+ ## Higher Order Functions
36
+
37
+ Higher order functions are simply functions that can take a function as an argument, or a function that returns another function.
You can’t perform that action at this time.
0 commit comments