Why does data binding not always work with primitives?

One of the milestones in learning JS and Angular is to learn that two-way data binding to primitives is complex. If you want to make sure that data binding works, you should always pack it into an object - that’s what some elderly people in my company told me. My question is: why is this happening? What exactly is happening, what makes data binding with the primitives that are so linked in JS?

I found out that Javascript passes objects by respect and primitives by value. So, what exactly happens, for example, in AnguleJS Controller, which allows us to bind a primitive in ngModel?

EDIT

Any articles, pointers are more than welcome!

+4
source share
1 answer

Good post or post here . Shortly speaking:

"Primitive values ​​(like numbers, strings) are immutable in JavaScript. Therefore, whenever a change is made to them, this means that we actually discard the previous instance and use another.

+1
source

All Articles