Créer un tableau immuable en javascript

let x = [1, 2, 3]
let [...y] = x

// let's update the value of "x"
x.push(4)

console.log(x) // will return [1, 2, 3, 4]
console.log(y) // will return [1, 2, 3]
/* "y" haven't changed because it copied the value of "x" and made himself
a whole separated array, instead of just coping the reference of "x"
(reference copy case:- let y = x) */
/* NOTE: get some youtube classes about javascript reference type and primitive
data types, if you're not clear enough about what i mean by "reference" */
maldito codificador