Você pode alterar os valores desta forma: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var locations = [ {lat: '', lng: ''} ] var markerElem = document.getElementById("div"); var newLat = markerElem.getAttribute('lat'); var newLng = markerElem.getAttribute('lng'); locations[0].lat = newLat; // altera lat locations[0].lng = newLng; // altera lng console.log(locations); <!-- language: lang-html --> <div id="div" lat="123" lng="456"></div> <!-- end snippet --> `locations[0]` seleciona o primeiro índice da array. Se quer adicionar um novo índice à array, pode fazer desta forma: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var locations = []; var markerElem = document.getElementById("div"); var lat = markerElem.getAttribute('lat'); var lng = markerElem.getAttribute('lng'); locations.push({ lat , lng }); console.log(locations); <!-- language: lang-html --> <div id="div" lat="123" lng="456"></div> <!-- end snippet -->