File tree 2 files changed +25
-1
lines changed
programming_paradigms/functional_programming
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 10
10
11
11
< div id ="content "> </ div >
12
12
13
- < script src ="ES6/Array_features/methods .js "> </ script >
13
+ < script src ="programming_paradigms/functional_programming/shared_state .js "> </ script >
14
14
</ body >
15
15
</ html >
Original file line number Diff line number Diff line change
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);
You can’t perform that action at this time.
0 commit comments