I have an object in AngularJS which stores my user data (called $scope.userData). The object looks something like this :
- user
- user_profile
- content
- sharing_data
- pages
- follows
- subscriptions
with each of those bullet points storing an array of vars. I would like to write a function to update any var stored within, for example I would like to update userData.sharing_data.pages[0], or delete userData.content[2], or add a value such userData.user.user_profile.profile_pic_url = 'myUrl';
How can I find and update any value in a nested object like this, without overwriting the whole object?