replace function in javascript array
<p>We know javascript array.push appends elements to the array. Is there an option to replace the elements in the array? The below function gets called twice and I have no control over event.mediaCollection.mediaIds. So mediaDTOs array gets populated with same number of mediaIds twice. I wish to prevent that from happening.I'm looking to add new mediaIds everytime this function is called instead of pushing mediaIds to the same array.</p>

<pre><code>function calledTwice(){
    var mediaIds = event.mediaCollection.mediaIds; 
    var mediaDTOs = [];
    for(var i = 0; i &lt; mediaIds.length; i++) {
            mediaDTOs.push({id:mediaIds[i]});
    }
}
</code></pre>

<p>Edit: Can't afford to create a temporary object to achieve this. Got to get the ids in the mediaDTOs array to be unique.</p>
