The dir
function prints the result of an async function to the console using console.dir
, which is compatible with Node.js and browsers that support console.dir
.
console.dir
behaves differently for different browsers. For instance, in Firefox, console.dir
prints a navigate-able list. In Chrome, log
and dir
act differently with arrays.
The following example shows how the dir
function may be utilized.
import dir from 'async/dir'; // Defines asynchronous function async function asyncFunc(){ return 'Return value'; } // Calling dir dir(asyncFunc);
This program shows a very basic use of dir
that takes the function as a parameter. It does not show any output because the dir
function uses console.dir
, which only works with browsers.
RELATED TAGS
View all Courses