const getType = (obj) => { return {}.toString.call(obj).slice(8, -1).toLowerCase(); } console.log(getType([])); // "array" console.log(getType({})); // "object" console.log(getType("")); // "string"