嘿,我想问你这两个代码段之间是否有任何区别。
//version 1
public async xxx(
item: Item
): Promise<any> {
const response = await function();
return this.merge(response);
}
//version 2
public async xxx(
item: Item
): Promise<any> {
const response = await function();
return await this.merge(response);
}
//Calling code:
const result = await this.xxx(item);
因此,在两种情况下,我都使用await语句调用xxx方法,但是在第一个示例中,我使用await返回,而在第二种示例中则没有。有什么不同?他们俩还是会返回Promise吗?