I genuinely thought that this feature, repeat task, will be an easy one, but it led me down the rabbit hole, searching and comparing best ways to clone a nested object.
while JSON.parse(JSON.stringify(task)) seemed the most straightforward option, it has many limitations(if the object has properties such as functions, undefined, Dates and other complex data structures, this method doesn't work)
then I got to option 1 , to spread the object and any nested keys it has. but in my opinion this works only for 1 level deep nesting, it would get complicated if there were several levels depth.
so then option 2, using a recursive function, although this is an expensive solution, imo the most efficient in this case, as deep cloning ensures the object is copied entirely including any nested properties.
so which one should i use?