To detect if argument is array instead of object with Node.js, we use the util.isArray method.
For instance, we write
const util = require("util");
const isArray = util.isArray([]);
to call util.isArray with an empty array to check if the argument is an array.
true is returned if it is.