Provided this code
let myVar = 'hey'
let myVar2 = myVar
myVar = 'what'
When I assign let myVar2 = myVar
, I am assigning a reference to myVar2
? Or in the assignation myVar
gets resolved and I am assigning the value that myVar
has at that moment?
My doubt is whether
myVar2
holds a reference towards the originalmyVar
(which is no longer available since it has been overwritten by the second assignationmyVar = 'what'
)- or
myVar2
holds since the beginning whatever value hadmyVar
, regardless that that variable will be overwritten later on