That is if I want to rewrite a function that is given below
getDefaultNodes(){
return this.defaultNodes;
}
engine.js
-----------------------------
const defaultNodes = engine.getDefaultNodes();
the place where its method is called.
as
async getDefaultNodes(){
return this.defaultNodes;
}
engine.js
-----------------------------
const defaultNodes = await engine.getDefaultNodes();
the place where its method is called.
Does this cause a performance issue? If yes, to what extent?
Does this bring about a performance loss?
Yes. There's some overhead in creating the promise, resolving it, waiting for it, breaking the code apart on the await, and scheduling continuations on the microtask queue. It also will prevent some possible optimisations (or at least make them much harder).
If yes, to what extent? Is it an issue?
It depends. Measure it if you care. It might not be significant, but still I'd argue that at least it is bad code.