hejialianghe / Senior-FrontEnd

🔥 🔥🔥 🔥🔥 高级开发工程师必备,打通全栈任督二脉,文档地址gitee版(Senior development engineers must understand the web body of knowledge, document addresses):https://js.youliaowu.com

Home Page:https://js.youliaowu.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2.6.1 memozition(缓存函数)的缓存判断语句好像可以调整下

827753181 opened this issue · comments

image
使用 !cache[address] 或者 !cache[key] 做判断会把0也判断进去,这也是
🍅 案例:求斐波那且数列
memoize后的fibonacci会执行12次的原因

是有这个情况

commented

image
这个地方的判断还是有点问题(缓存函数)

image
如果cache[key] 获取到为 0 或者 空字符串或者 false 还是会重新计算,我觉得可以判断 一下cache[类型] 是否为 undefined 类型

commented

已改