To clone an object with Node.js, we use the Lodash clone
method.
For instance, we write
const _ = require("lodash");
const objects = [{ a: 1 }, { b: 2 }];
const cloned = _.clone(objects);
to call clone
to clone the objects
array and return the clone.