Skip to content

Commit 2be5d8d

Browse files
author
Vitalii Telychko
committed
commit
1 parent 661a26f commit 2be5d8d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
<div id="content"></div>
1212

13-
<script src="ES6/Array_features/methods.js"></script>
13+
<script src="programming_paradigms/functional_programming/shared_state.js"></script>
1414
</body>
1515
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// const x = {
2+
// val: 2
3+
// };
4+
//
5+
// // Mutates shared state
6+
// const x1 = () => x.val += 1;
7+
// // Mutates shared state
8+
// const x2 = () => x.val *= 2;
9+
//
10+
// // if reverse invocations => result changed
11+
// x2();
12+
// x1();
13+
//
14+
// console.log(x.val);
15+
16+
// Immutable state
17+
// const x = {
18+
// val: 2
19+
// };
20+
//
21+
// const inc = x => ({ ...x, val: x.val + 1 });
22+
// const double = x => ({ ...x, val: x.val * 2 });
23+
//
24+
// console.log(double(inc(x)).val);

0 commit comments

Comments
 (0)