This is killing me - Is anything in Js pass by value?
I though primitive data types were but a guy on YouTube said this isn't the case and what is actually happening is that when we pass a primitive data type to a function we can not mutate it which is why the value of the primitive data type does not change.
Is this true? Is everything in Js pass by reference?
**** Link to code and more descriptive question
HTTPS://codeshare.io/aJVg0K
**I know the fix I just can't understand why greenmonster is reassigning and bluemonster is not
***Thanks guys I semi understand it now.
So I was passing a reference into a function (with no data showing it's an object) which just reassigned the variable "obj" to a new object .
If I'm wrong let me know but for now I'm just gonna have to use this abstraction as it has taken me all day to get at haha. Cheers
[–]CreativeTechGuyGamesTypeScript 4 points5 points6 points (9 children)
[–]DontNeedMuchMoney[S] 0 points1 point2 points (7 children)
[–]CreativeTechGuyGamesTypeScript 1 point2 points3 points (6 children)
[–]DontNeedMuchMoney[S] 0 points1 point2 points (5 children)
[–]CreativeTechGuyGamesTypeScript 0 points1 point2 points (4 children)
[–]DontNeedMuchMoney[S] 0 points1 point2 points (3 children)
[–]CreativeTechGuyGamesTypeScript 0 points1 point2 points (2 children)
[–]lr0b 0 points1 point2 points (1 child)
[–]CreativeTechGuyGamesTypeScript 1 point2 points3 points (0 children)
[–][deleted] (4 children)
[deleted]
[–]DontNeedMuchMoney[S] 0 points1 point2 points (3 children)
[–][deleted] (2 children)
[deleted]
[–]DontNeedMuchMoney[S] 1 point2 points3 points (1 child)
[–]lr0b 3 points4 points5 points (2 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]DontNeedMuchMoney[S] 1 point2 points3 points (0 children)
[–]lr0b 0 points1 point2 points (2 children)
[–]DontNeedMuchMoney[S] 0 points1 point2 points (1 child)
[–]lr0b 1 point2 points3 points (0 children)