Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b403314

Browse files
Update README.md
1 parent 66972ce commit b403314

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎L-A/0014 Memoize II/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,25 @@ For the inputs of (2, 2): 2 + 2 = 4, and it required a call to fn().
2424
For the inputs of (2, 2): 2 + 2 = 4, but those inputs were seen before so no call to fn() was required.
2525
For the inputs of (1, 2): 1 + 2 = 3, and it required another call to fn() for a total of 2.
2626
```
27+
28+
## Example 2:
29+
```javascript
30+
Input:
31+
getInputs = () => [[{},{}],[{},{}],[{},{}]]
32+
fn = function (a, b) { return ({...a, ...b}); }
33+
Output: [{"val":{},"calls":1},{"val":{},"calls":2},{"val":{},"calls":3}]
34+
Explanation:
35+
Merging two empty objects will always result in an empty object. It may seem like there should only be 1 call to fn() because of cache-hits, however none of those objects are === to each other.
36+
```
37+
38+
39+
## Example 3:
40+
```javascript
41+
Input:
42+
getInputs = () => { const o = {}; return [[o,o],[o,o],[o,o]]; }
43+
fn = function (a, b) { return ({...a, ...b}); }
44+
Output: [{"val":{},"calls":1},{"val":{},"calls":1},{"val":{},"calls":1}]
45+
Explanation:
46+
Merging two empty objects will always result in an empty object. The 2nd and 3rd third function calls result in a cache-hit. This is because every object passed in is identical.
47+
```
48+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /