Skip to content

Commit aee12fb

Browse files
committed
closures & prototypal inheritance
1 parent d35d0b4 commit aee12fb

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

ClosuresPrototypalInheritance.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.

0 commit comments

Comments
 (0)