Update function-table-clone.md

This commit is contained in:
Arseny Kapoulkine 2022-02-14 10:39:52 -08:00 committed by GitHub
parent 480ccd2d45
commit c03c31cd6f
Signed by: DevComp
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,8 @@ operation so from the ergonomics perspective it can be expected to be provided b
- has the same keys and values
- is not frozen, even if `t` was
The copy is shallow: implementing a deep recursive copy automatically is challenging (for similar reasons why we decided to avoid this in `table.freeze`), and often only certain keys need to be cloned recursively which can be done after the initial clone.
The table can be modified after cloning; as such, a primitive like `Object.assign` could be built on top of this.
`table.clone(t)` is functionally equivalent to the following code, but it's more ergonomic (on the account of being built-in) and significantly faster: