DEV Community

Discussion on: How to duplicate array

Collapse
 
madrafj profile image
Ahmad Rafsanjani

I wonder how people do it before spread operator exists ?..

Collapse
 
elukuro profile image
Heru Hartanto

I did this 😆

const a =[1,2,3]
const b = a.slice()
b.push(4)
console.log(a,b)
Enter fullscreen mode Exit fullscreen mode
Collapse
 
madrafj profile image
Ahmad Rafsanjani

Aah..got it.. thanx