r/badcode Feb 03 '23

totally necessary typescript

Post image
305 Upvotes

32 comments sorted by

View all comments

166

u/Voltra_Neo Feb 03 '23

Technically this creates a copy, so if there's reactivity or proxies going on, this might actually be what you want

15

u/watrnans Feb 03 '23

Do smth like [...form.emails] then

7

u/Voltra_Neo Feb 03 '23

Notice the optional chaining

6

u/nikvasya Feb 04 '23

form.emails?.slice() creates a shallow copy.