Chalarangelo / 30-seconds-of-code

Short code snippets for all your development needs

Home Page:https://30secondsofcode.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

why deepClone do not use clone but obj

henrycjchen opened this issue · comments

commented

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?

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.

commented

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.