Closed sangupta closed 6 years ago
You are right in this particular instance, but Eloquent Javascript is a beginner's book, so I think it is sensible to spell out the full example. Without memoization this just a toy implementation anyway.
Agreed. Just a thought around adding a comment to the code to let reader's know that they may skip it out.
Yeah this is intentional. Sure it's technically redundant, but it's entirely harmless and makes the code easier to scan. You'll see more code like that throughout the book.
The
else
block in the code example below is redundant - as it is immediately preceded by areturn
statement. Code sample is as under:The code block is available on this page: https://eloquentjavascript.net/3rd_edition/00_intro.html
There are other occurrences where the same pattern is used. I can help send a PR if needed.