addyosmani / addyosmani/backbone-fundamentals

Shallow copy or deep copy?

未关闭
#665 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rich Text Format
星标
9.2k
派生
1.4k
PR 合并指标
30 天内没有已合并 PR

描述

The note about the `attributes` object passed to `validate()` says:

> This object is distinct from the current attributes of the model and from the parameters passed to the operation. Since it is created by **shallow copy**, it is not possible to change any Number, String, or Boolean attribute of the input within the function, but it is possible to change attributes in nested objects.

So, the nested objects can be changed because they are deep copied? Aren't nested objects the ones that are shallow copied and everything else (direct members of attributes object) is deep copied?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。