martin ↑ pfp
martin ↑
@martin
just learned typescript passes object by reference not value unlock
2 replies
0 recast
11 reactions

nishu pfp
nishu
@nishu
since javascript 😅
1 reply
0 recast
1 reaction

martin ↑ pfp
martin ↑
@martin
Yeah I guess it’s a JavaScript thing Just had no idea for some reason, assumed it was all by value not reference
2 replies
0 recast
1 reaction

iain pfp
iain
@iain
there's a nice cloneDeep module for this that does what you think for cloning. if it's just a normal object you can do Object.assign({}, objectToClone) to clone.
1 reply
0 recast
1 reaction

nishu pfp
nishu
@nishu
yeah its probably the only language that does this an example for those who read this let a,b; a = 10 b = a b = b + 1 console.log(a) will return 11 🙃 (no smiley) this will get really annoying when you start dealing with arrays so [...arr] to copy contents is better
0 reply
0 recast
0 reaction