Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update clone.js #51

Merged
merged 1 commit into from
May 1, 2023
Merged

Update clone.js #51

merged 1 commit into from
May 1, 2023

Conversation

woodcoal
Copy link
Contributor

Map 在 forEach 的时候,参数分别为:值,键,对象
因此 set 的时候需要将键也设置进去

case "[object Map]": {
        var restMap = getCativeCtor(val)
        restMap.forEach(function (item, key) {
          restMap.set(handleValueClone(item, isDeep))
        })
        return restMap
      }

应该为: restMap.set(key, handleValueClone(item, isDeep))

Map 在 forEach 的时候,参数分别为:值,键,对象
因此 set 的时候需要将键也设置进去

```
case "[object Map]": {
        var restMap = getCativeCtor(val)
        restMap.forEach(function (item, key) {
          restMap.set(handleValueClone(item, isDeep))
        })
        return restMap
      }
```

应该为: ```restMap.set(key, handleValueClone(item, isDeep))```
@xuliangzhan xuliangzhan merged commit 5481bd9 into x-extends:master May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants