I'm currently learning how to use and apply a dataLayer to a website. From everything that I've read, best practice is to use .push functionality when updating your dataLayer.
I know that .push will not usually update an object's value that is inside of an array when you use the .push functionality, it will simply append another object with the same key and new value to the end of it. Google Tag Manager has patched the .push functionality to allow it to see if the key exists and change it's value, or if it doesn't exist, add a new object to the array.
How does GTM accomplish this, and can I write code to do this myself? Secondary question, as I am using Adobe Analytics on this website, does AA/Launch have this same functionality? I may want to update something in the dataLayer and won't know it's index within the array.
Thanks!