todo -repeat task
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?
3
2 comments
Mioara Cenusa
7
todo -repeat task
Developer Pro
skool.com/developerpro
Learn how to code. Make money. Have fun. Enjoy life.
Leaderboard (30-day)
Powered by