30-seconds-of-code: why deepClone do not use clone but obj

Created on 16 Aug 2020  路  4Comments  路  Source: 30-seconds/30-seconds-of-code

In the snippets/deepClone, there is a case to return Array.from(obj), which make the clone object useless, is it correct to do so?

question

All 4 comments

I believe Array.isArray(obj) checks if obj is of type Array. Array.from(obj) is the deep clone of the array .Correct me if I am wrong.

We're looking into this. I'll get back to you.

I believe Array.isArray(obj) checks if obj is of type Array. Array.from(obj) is the deep clone of the array .Correct me if I am wrong.

Array.from is actually the shallow copy of the array. You can check it from here.

Solved in de38320. The code was simplified and some notes were added for this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Chalarangelo picture Chalarangelo  路  5Comments

YusofBandar picture YusofBandar  路  5Comments

Bruce-Feldman picture Bruce-Feldman  路  4Comments

fejes713 picture fejes713  路  4Comments

Greenheart picture Greenheart  路  3Comments