1
I have the following situation:
let a=[{nome:"oi"},{nome:"xau"}]
let b=Object.assign([], a)
b[0].nome=5
console.log(b) //[{nome:5},{nome:xau}]
console.log(a) //[{nome:5},{nome:xau}]
A little while ago I asked here how to pass values without reference, I was told to use Object.assing, but still it is not working, someone can help me as I would change the b[0]. name without changing the a?
Have you tried using the same
a
, in the first assign parameter?– Valdeir Psr
type Object.assign([{}],a)? I’ve tried this and it didn’t work
– Thiago Outeiro Pereira Damasce