javascript change object's property and return it I have to change a object's property and keep all other properties. After the change, I need to push the object into an array. However, because of asynchronous issue (this is my guess), the value pushed is still the initial object. How can I solve the problem? Here is my code:
layer.features.forEach(function(feature){
  var geometry = feature.geometry;
  var igeometry = geometry.transform("EPSG:4326");
  feature.geometry = igeometry;
  myFeature.push(feature);
});

In the code, the feature pushed into myFeature[] is always the initial feature with geometry instead of new feature with igeometry.

You should try to log to console geometry, igeometry, feature and make sure that they are all your expected value. From looking at your code it should work. So for example.
https://repl.it/INoA
let arr = [{a: 1}, {a:2}, {a:3}, {a:4}];
function wait(item) {
    return new Promise (resolve => {
item.a = item.a + 1;
setTimeout(resolve, 100, item);
    });
}
let newArr = arr.map(item => {
   return wait(item);
});

Promise.all(newArr).then(values => {
    console.log(values);
});

You have a couple of options for your promises. You can either resolve it inside the promise, or you can use the new await method in which does the same thing.
http.get('someGetAddres').then(result => {
var myFeature = [];
layer.features.forEach(function(feature){
var geometry = feature.geometry;
var igeometry = geometry.transform("EPSG:4326");
feature.geometry = igeometry;
myFeature.push(feature);
    });
});

async function getFeature() {
    var layer = await http.get('myWebsite');
    var myFeature = [];
    layer.features.forEach(function(feature){
var geometry = feature.geometry;
var igeometry = geometry.transform("EPSG:4326");
feature.geometry = igeometry;
myFeature.push(feature);
    });
}