How check if a function is async in JavaScript

2 Answers

0 votes
async function func() {

}

const isAsync = func.constructor.name === "AsyncFunction";

console.log(isAsync);
 
  
  
  
   
/*
run:
   
true
   
*/

 



answered Dec 22, 2021 by avibootz
0 votes
const func = async (a, b) => {
 
};
 
const isAsync = func.constructor.name === "AsyncFunction";
 
console.log(isAsync);
  
   
   
   
    
/*
run:
    
true
    
*/

 



answered May 26, 2022 by avibootz

Related questions

2 answers 147 views
2 answers 161 views
1 answer 227 views
1 answer 137 views
1 answer 123 views
1 answer 212 views
1 answer 160 views
...