DEV Community

Discussion on: What’s your alternative solution? Challenge #53

Collapse
 
miketalbot profile image
Mike Talbot ⭐

Probably the easiest way:

const copy = src => JSON.parse(JSON.stringify(src))

Alternatively:

const copy = ar => [...ar.map(a => (Array.isArray(a) ? copy(a) : a))]