new object.assign + array.push vs _cloneDeep

I need to clone some objects from the resultset after a wix-data query to a new array of objects.

Found out that object.assign(wixItemRow) adds “garbage” to the new array, see https://stackoverflow.com/questions/728360/how-do-i-correctly-clone-a-javascript-object
and
http://blog.bogdancarpean.com/deepcopy-of-javascript-objects-and-arrays-using-lodashs-clonedeep-method/

So I have 2 alternatives:
a)assigning every key:value pair to a new var holding the same data, then, when all fields done, do object.assign and then .push it to an array
b) use lodash cloneDeep

My question: which would be quicker?

P.S: the well-known trick JSON.parse/stringify won´t work, resultset holds many dates.

What do you mean by “adds garbage”? Do you mean that you need a deep cloning instead of shallow cloning?

From the Stackoverflow forum as quoted above:
" You will run into the problem of erroneously picking up attributes from the object’s prototype that should be left in the prototype and not copied to the new instance. "
and
" In addition to non-enumerable attributes, you’ll encounter a tougher problem when you try to copy objects that have hidden properties. "

I think this explains why I wrote there was info in the array of objects that I didn´t put there (lik “skip”, “limit”, in a different syntax than when you stringify the object.

SO yes, I either need to deep clone an object (lodash) or getting all the key value pairs, assign the identical pairs to a new object (object.assign) and .push it onto a new array.

I wonder which is quicker.

@giri-zano These quotes don’t refer to Object.assign().
I’ve never had a problem with it, but maybe it depends on the specific data.
You can try to find out what to do with your dates and use JSON.stringify parse() that can be handled if the dates are in a specific format.
You can also delete the unwanted keys from the objects. something like:

let keysToDelete = ["skip", "limit"/*etc*/];
newArray.forEach(e => {
for (let i = 0; i < keysToDelete .length; i++){
delete e[keysToDelete[i]];
}
})

Alternatively you can set these values to be undefined (so they won’t get into the database):

 let keysToDelete = ["skip", "limit"/*etc*/];
newArray.forEach(e => {
for (let i = 0; i < keysToDelete .length; i++){
e[keysToDelete[i]] =  undefined;
}
})//faster than delete