Skip to content

Commit

Permalink
fix(function.md): 修改缓存函数判断
Browse files Browse the repository at this point in the history
fix#40
  • Loading branch information
hejialiang committed Feb 16, 2023
1 parent 225d8bc commit 0fda26a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/engineering/function.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ calculate(10, 20) // 相同的参数,第二次调用是,从缓存中取出
let memoize = function(func) {
let cache = {}
return function(key) {
if (!cache[key] || (typeof cache[key] === 'number' && !!cache[key])) {
if (!cache.hasOwnProperty(key) ) {
cache[key] = func.apply(this, arguments)
}
return cache[key]
Expand Down

0 comments on commit 0fda26a

Please sign in to comment.