How to use async await function object in Javascript?
问题 Say I have a function object- setObj : function(a,b){ obj.a = a; obj.b = b; } If I have to use async & await on this function object, how do I do it? If the same was written in function (function way), say- async function setObj(a,b){ obj.a = a; obj.b = b; } await setObj(2,3); This works fine. But, how do I do it in case of function object? 回答1: If I understand your question correctly, you can just use the async keyword in front of the method declaration: let obj = {}; let myObj = { async