I found this example on jetbrains.com
async function getWeather(cityid: number){
var weather = await getForecast(cityid);
var {t: temperature, h: humidity} = weather;
return { temperature, humidity};
}
I understand async / await, but I'm trying to figure out what happens with the last two lines.
var {t: temperature, h: humidity} = weather;
As far as I can tell, this creates a var with two properties, t type temperature and h type humidity.
return { temperature, humidity};
It seems to me that it returns a new object with two child objects, temperature and humidity. I do not understand how this is obtained from the weather object.
I don't know if this is a javascript question or typescript question, so I am tagged as both.
source
share